This is the mail archive of the
mailing list for the binutils project.
- To: email@example.com
- Subject: symbol relocation
- From: Todd_Manchester@nmss.com
- Date: Thu, 8 Jul 1999 16:03:22 -0500
I am trying to compile code for m68k, with the output format m68k-aout.
I can compile all the code, and link it to produce a relocatable object
file that is loaded by custom written loader (which utilizes the bfd
However, the object file that is produced has what appear to be incorrect
refences to global variables, that is their location seems to be wrong.
For example, for the following code:
/* test.c */
char *str = "Test string 1";
void strdummy(char* s)
s = 't';
int main ()
char *str2 = "test String 2";
str = "test string 3";
str2 = str;
I compile with:
gcc -save-temps -Wa,-L -m68000 -g -x c -c -o test.o test.c
gcc -nostartfiles -Wl,--entry=.main,-r,-Map=test.map -o test.ro test.o
(This is a test case, the two step compilation is to mimic more complex
I then do the following:
objdump -x test.ro > test_ro.txt
objdump -d --line-numbers test.ro > test_ro.s
Looking at the output, I see what appear to be some problems with sybol
In the original assembly the line is (test.s):
In the disassembled output, the line is (test_ro.s):
50: 2f39 0000 0094 movel 94 <___do_global_dtors+0x18>,%sp@-
I believe this to be wrong, because the the value of the symbol _str is not
0x0000 0094, but is 0x00000110
This is shown in the line below from the symbol listing produced by objdump
00000110 g .data 0000 00 07 _str
Why is the value in the code different from the symbol listing value (which
I believe to be correct)?
All the relocation entries point to symbols such as .text, .data, and .bss;
is there any way to find the
actual symbol that was being referenced? (that way I could compute my own
Am I not understanding the relocation process correctly?
I have look through the bfd source some; where can I go for more
Some other information:
There is a relocation entry for this address (from test_ro.txt):
00000052 32 .data+0xfffffef0
I am using the cygwin development environment, cygwin-b20.1
with gcc version egcs-2.91.57 19980901 (egcs-1.1 release), configured with
I think this is causing programs that are loaded by my loader to address
incorrect locations in memory.
The loader is using the bfd library to perform final linking at load time
(to place the code at the correct address).
The loader sets up appropriate data structures and calls bfd_final_link()
to perform the final link.
It then extracts the section contents and loads them into memory.
Any suggestions as to what is happening with these symbols or this code
would be appreciated.
Also any hints as to how to proceed or problems with my approach would be
I can provide more details if necessary.