\hypertarget{interface_synopsis}{}\subsection{Synopsis}\label{interface_synopsis}
\hypertarget{interface_name}{}\subsubsection{Name}\label{interface_name}
{\tt elfreloc} - PPC ELF file strip/relocation utility\hypertarget{interface_usage}{}\subsubsection{Usage}\label{interface_usage}
{\tt  elfreloc {\em  in\_\-file out\_\-file \/} }

{\tt  {\em in\_\-file\/} } - The name of the ELF file to process. \par
 {\tt  {\em out\_\-file\/} } - The name of the processed output file.\hypertarget{interface_description}{}\subsection{Description}\label{interface_description}
The {\tt elfreloc} utility may be helpful in reducing the size of 32-bit ELF object file for the PPC machine type. The embedded Vx\-Works loader uses relocatable (type ET\_\-REL) ELF objects. These files can contain numerous relative address relocation entries (type R\_\-PPC\_\-REL24) for the {\em \/}.text section. If these entries refer to other global functions within the same object file, they are not strictly neccessary since the relative address spacing between function objects is known at build time. For the {\em elfreloc\/} application to successfully strip the relative relocation entries, the following restrictions apply: \par


\begin{itemize}
\item The file must be of class type ELFCLASS32 (1).\item The file must be of data type ELFDATA2MSB (2).\item The file must be of ELF type ET\_\-REL (1).\item The file must be of machine type EM\_\-PPC (20).\item The resulting output object file should not be processed by the host linker such that the {\em \/}.text section is split or joined with other sections.\item The Vx\-Works 5.5 loader should be used.\end{itemize}


The Vx\-Works 5.5 loader does not tamper with the relative addressing of the {\em \/}.text section, so it essentially never notices that the relative relocation entries have been removed. When creating the output ELF object file, {\tt elfreloc} will leave intact those relative relocation entries that refer to external, undefined symbols. The Vx\-Works loader still needs these entries to properly link the object file into the target system.

Once the relative relocation entries have been removed by {\tt elfreloc}, it may be possible to further reduce the size of an ELF object file by using a symbol reduction utility (GNU {\tt ld} and {\tt objcopy} are examples). Users may have defined global symbols in mutilple modules for use at build time, but not all of those symbols are expected to be global visible in the target run time environment. Unfortuntely, the default behavior of the Vx\-Works host build tools is to place these global symbols in the ELF object file symbol table and then to refer to these symbols with {\em \/}.text relocation entries whenever they are called as a function. Because the symbol entries are tied to the relocation entries, it is not possible to delete the symbol entries even though they may not be needed on the target. With the {\tt elfreloc} tool, some of these relocation entries may be deleted, freeing up the symbol table entries for later removal.

The {\tt elfreloc} utility does not modify the contents of any section other than the {\em \/}.text and {\em \/}.rela.text sections, and only modifies the ELF file control structures (file header, section headers) in order to reflect the new output file's more compact size. 