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: binutils + 16-bit code issues


On Fri, Sep 22, 2017 at 05:04:53PM -0700, Anatol Pomozov wrote:
> $ as boot.S -o boot.o
> $ ld boot.o -o boot --oformat binary
> boot.o: In function `_start':
> (.text+0x5): relocation truncated to fit: R_X86_64_16 against `.text'+28
> boot.o: In function `_start':
> (.text+0x12): relocation truncated to fit: R_X86_64_16 against `.text'+32
> 
> Unfortunately the error message does not make it easy for me to
> understand what is going on here. And how to fix the error. After

You are using a linker that by default produces binaries to run on a
Linux system, so for x86_64 they start at around 0x400000.  ".text+28"
is way out of the range of a 16-bit reloc.  You probably want your
binary to be linked at address zero.  The best way to do that is to
write a small linker script.  See the ld info doc for examples.

-- 
Alan Modra
Australia Development Lab, IBM


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