This is the mail archive of the
mailing list for the binutils project.
Re: x86-64 push / jmp / mov of undefined label results in bad relocation for position-independent code
- From: Bruno Loff <bruno dot loff at gmail dot com>
- To: Jan Beulich <JBeulich at suse dot com>
- Cc: binutils at sourceware dot org
- Date: Tue, 22 Aug 2017 15:58:49 +0100
- Subject: Re: x86-64 push / jmp / mov of undefined label results in bad relocation for position-independent code
- Authentication-results: sourceware.org; auth=none
- References: <CAGOfsMg_wV92F+cnvdmMh9HyVytu0N6PUDo=Tz23GcVzZPruzw@mail.gmail.com> <599C34BD0200007800171F7E@prv-mh.provo.novell.com>
Ah, I see my sparse knowledge of assembly was to blame.
Using `movabs` I got it to work perfectly.
Thank you for taking your time to answer my noob question.
On 22 August 2017 at 12:42, Jan Beulich <JBeulich@suse.com> wrote:
>>>> On 22.08.17 at 13:25, <email@example.com> wrote:
>> When compiling an x86-64 assembly file which contains a `push`, `jmp`
>> or `mov` instruction having an undefined label as an operand, `as`
>> generates a relocation of type `R_X86_64_32S`, which is only 32bit
>> long, i.e., it is too short for position-independent code (since such
>> code might be loaded onto a position outside the 32-bit address
> Of course. All three named mnemonics have only 32-bit immediate
> operands, so a wider relocation cannot possibly be used with them.
> You'll need to go through a register, using movabs or lea to load
> the intended value into it.