Re: Jump addresses messed up with GNU as



> Yes, it is. Do you use linker?

I didn't. But I have a similar problem when using GCC (I downgraded to GCC
3.4.3 and Binutils 2.14 to see if it was a GCC4 bug, but it is not), for
example with the following program :

int main(void)
{
int i;

for(i=0;i<10000;i++);
(...)

I compile it with :

$ arm-elf-gcc -O2 -Wall -g -mcpu=arm7tdmi main.c -c -o main.o
$ arm-elf-gcc -O2 -Wall -g -mcpu=arm7tdmi -s -o monitor.o main.o
$ arm-elf-objcopy -I elf32-little -O binary main.o monitor.arm

(I tried various flags, same problem)

Then I check the final output :

$ arm-elf-objcopy -I binary -O elf32-littlearm monitor.arm temp.o
$ arm-elf-objdump -marm7tdmi -D temp.o

00000000 <_binary_monitor_arm_start>:
0: e3a03c27 mov r3, #9984 ; 0x2700
4: e2833010 add r3, r3, #16 ; 0x10
8: e2533001 subs r3, r3, #1 ; 0x1
c: 1a000000 bne 14 <_binary_monitor_arm_start+0x14>
(...)

The jump address is incorrect : it should be _binary_monitor_arm_start+0x08
instead (and the code actually fails because of that when loaded in the
CPU).

But the intermediate object file looks correct :

$ arm-elf-objdump -d main.o

00000000 <main>:
0: e3a03c27 mov r3, #9984 ; 0x2700
4: e2833010 add r3, r3, #16 ; 0x10
8: e2533001 subs r3, r3, #1 ; 0x1
c: 1a000000 bne 8 <main+0x8>

Any clue ?


.



Relevant Pages

  • Re: How a linker works (continued)
    ... int tab; ... warnings* not even at the highest warning level. ... In the linker of lcc-win I added a warning: ... knocking gcc without understanding it so... ...
    (comp.lang.c)
  • Re: Undefined symbol in gcc & c++
    ... > I built the following little C program into a library with gcc: ... > int foo() { ... The C compiler does no such thing, and for the linker to ...
    (comp.unix.programmer)
  • Re: Linux C++ compiling woe
    ... > int main ... The gcc man page says that gcc recognizes files with the ... These are *linker* errors. ... Invoking the compiler through calls ...
    (comp.unix.programmer)
  • Re: data types
    ... Usually short is smaller than an int. ... Your compiler is either *really* old or broken or both. ... recommend either a version of gcc,, or Visual Studio ... Microsoft's Visual Studio Express has an onerous EULA). ...
    (comp.lang.c)
  • Re: stream io in c
    ... zero to 255, putchar'ing in the body of the loop, then redirecting output ... int main ... // gcc -o chars mkchars1.c ... This compiles but gcc warns of incompatible pointer types. ...
    (comp.lang.c)