This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: binutils + 16-bit code issues
- From: Alan Modra <amodra at gmail dot com>
- To: Anatol Pomozov <anatol dot pomozov at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Mon, 25 Sep 2017 11:08:10 +0930
- Subject: Re: binutils + 16-bit code issues
- Authentication-results: sourceware.org; auth=none
- References: <CAOMFOmWgK9yVz1LJ-h_GqpGbYRkJTf1-uwrrfmkAe0F057f8mQ@mail.gmail.com>
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