11.07.2015 Views

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Linker and UtilitiesLibrarianreducing the size of these functions’ local memory will have no affect on the program’s RAM usage.Their memory usage could be increased, as long as the total size of the memory used by these twofunctions did not exceed that of sprintf(), with no additional memory used by the program. So ifyou have to reduce the amount of RAM used by the program, look at those functions that are starred.If, when searching a call graph, you notice that a function’s parameter and auto areas have beenoverlapped (i.e. ?a_foo was placed at the same address as ?_foo, for example), then check tomake sure that you have actually called the function in your program. If the linker has not seen afunction actually called, then it overlaps these areas of memory since that are not needed. This isa consequence of the linker’s ability to overlap the local memory areas of functions which are notactive at the same time. Once the function is called, unique addresses will be assigned to both theparameters and auto objects.If you are writing a routine that calls C code from assembler, you will need to include the appropriateassembler directives to ensure that the linker sees the C function being called.5.10 LibrarianThe librarian program, LIBR, has the function of combining several object files into a single fileknown as a library. The purposes of combining several such object modules are several.• fewer files to link• faster access• uses less disk spaceIn order to make the library concept useful, it is necessary for the linker to treat modules in a librarydifferently from object files. If an object file is specified to the linker, it will be linked into the finallinked module. A module in a library, however, will only be linked in if it defines one or moresymbols previously known, but not defined, to the linker. Thus modules in a library will be linkedonly if required. Since the choice of modules to link is made on the first pass of the linker, andthe library is searched in a linear fashion, it is possible to order the modules in a library to producespecial effects when linking. More will be said about this later.5.10.1 The Library FormatThe modules in a library are basically just concatenated, but at the beginning of a library is maintaineda directory of the modules and symbols in the library. Since this directory is smaller thanthe sum of the modules, the linker is speeded up when searching a library since it need read onlythe directory and not all the modules on the first pass. On the second pass it need read only thosemodules which are required, seeking over the others. This all minimises disk I/O when linking.103

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!