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:

> int global_a, global_b;

In C, by default, these are common symbols.  They won't be defined in
the .bss section of the .o file.  If the linker does not see another
definition, it will eventually allocate them in the .bss section, but
this will be independent of your head.s and tail.s files.  You can
change this behaviour with gcc's -fno-common option, q.v.

> (a) my_data_start is missing, only my_data_end appears.  (If, however,
> I only include head.o in my Makefile,rule, then my_data_start appears
> in the location where my_data_end appears in the above extract.)

I think my_data_start is missing because of the way you are examining
the .o file.  There are two symbols at the address of
my_data_start--my_data_start and the first symbol in the .bss section.
objdump -D happens to be showing you just one of them.  Use readelf -s
or objdump -t or nm.

> (b)  my_data_end is separated from global_a and global_b and seems to be in an arbitrary location in relation to them.

That's because they are common symbols.

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