This is the mail archive of the 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

Hello Alan. Thanks for your reply.

Yep after looking at the content of 'ld --verbose ...' output I
finally figured out that section is relocated to some high value. So I
added 'ld -Ttext-segment=0' command line parameter that tells linker
to relocate .text to address 0.

And in my real project (that uses a linker script) I added start
address for the section that contains 16-bit code

.boot.trampoline 40K : {

Now my 16-bit code links fine so my issue is resolved. But I would
love to see a bit more understandable 'ld' error message that explains
me more clearly what was wrong with my code. 'relocation truncated to
fit' is a bit confusing unfortunately.

On Sun, Sep 24, 2017 at 6:38 PM, Alan Modra <> wrote:
> 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]