Re: Inserting labels before and after my program's global variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Amittai Aviram <amittai.aviram@xxxxxxxx> writes:

> I would like to insert labels into my executable as it is being linked
> so that there is a "start" label just before my user-defined global
> variables in the .bss section and an "end" right after them, when I
> use static linkage.  Thus the output of .bss from objdump -D would
> include some lines something like this, supposing I had global
> variables global_a and global_b:

This is the kind of thing which is much more easily done using a linker
script.


> Here is what I tried (but it didn't work).  I wrote a file head.s and
> one called tail.s:

> gcc -static -o hello head.s hello.c tail.s

This does not actually put the files first and last.  To see why not,
add the -v option and look at the linker command.  To put the files
first and last, you will have to use -nostdlib to disable gcc's default
start files and libraries, and then replicate them on the command line
yourself, with head and tail where you want them.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux