This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Wrong jump/branch-offsets with assembler startup


Am 16.03.2013 03:02, schrieb Alan Modra:
> On Fri, Mar 15, 2013 at 06:50:25PM +0100, Jens Mehler wrote:
>> Whenever I try assemble with two files let's call them start.s (that
>> handles setting the stack poiner and jumping to main) and hello.s (that
>> contains code to emit a string) the jump/branch offsets are off by one.
>> This is not the case for jumping to main, it is however everywhere
>> starting from main i.e. in main in a jump to foo this jump is off by one
>> (negative one) while the offset from start to main is spot on.
>>
>> The problem vanishes when I put the stuff from start.s into hello.s
>>
>> Could someone please give me a pointer on how to solve this problem?
> First examine your object files.  Are the relocations correct?  If
> not, you have an assembler problem rather than a linker problem.
>
I was able to force this error by doing the following:
gcc -S main.c
as -o start.o start.s
as -o end.o end.s
as -o main.o main.s
ld -o main.elf start.o main.o end.o

now the offsets for jumps and branches are wrong too.
The entries of the relocations are okay.
But as soon as I link them stuff gets messy.

Maybe I forgot to implement some stuff that is important to get this
working correctly.

~ Jens


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