Turn Off Linker Warnings with -w

In some build processes you might want to improve parsing of build output by ignoring linker warnings. You can turn off linker warnings with the -woption.

Preserving Compiler Generated Relocation Sections with -emit_relocs

The -emit_relocsoption enables the linker to preserve compiler-generated relocation sections in the output binary. The input relocation information is stored in the executable, or the shared library. This information provides the necessary support for third-party programming tools to perform post-link instrumentation.

The following example illustrates that the compiler generated relocation sections (such as

.rela.text, and .rela.IA64_64.unwind) are copied to the output binary with -emit_relocs:

$ cc -c main.c

$ ld -emit_relocs main.o -lc

$ elfdump -h -S a.out grep rela

7 RELA 04000740 00000740 0000000c .rela.plt

30RELA 00000000 00010304 00000024 .rela.IA_64.unwind

31RELA 00000000 00010328 0000000c .rela.IA_64.unwind_info

32RELA 00000000 00010334 00000024 .rela.text

34RELA 00000000 00010398 0000000c .rela.debug_line

36RELA 00000000 000103d8 0000000c .rela.debug_actual

39RELA 00000000 00010470 0000003c .rela.debug_procs_info

The following example illustrates that only the linker genereated relocation sections are copied to the output binary if -emit_relocsis not used:

$ ld main.o -lc

$ elfdump -h -S a.out grep rela

7 RELA 040006ec 000006ec 0000000c .rela.plt

The compiler generated relocation sections are not copied to the output binary if -emit_relocsis not used.

52 Determining How to Link Programs or Libraries (Linker Tasks)

Page 52
Image 52
HP UX Software Transition Kit (STK) manual Turn Off Linker Warnings with -w