This is the mail archive of the mailing list for the crossgcc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

sybol relocation problems

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[0] = '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, -o 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.txt
     objdump -d --line-numbers > test_ro.s

Looking at the output, I see what appear to be some problems with sybol
For instance:
In the original assembly the line is (test.s):
     movel _str,sp@-
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)?

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.

-Todd Manchester

New CrossGCC FAQ:
To remove yourself from the crossgcc list, send
mail to with the
text 'unsubscribe' (without the quotes) in the
body of the message.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]