This is the mail archive of the
mailing list for the binutils project.
Re: Avoiding unnecessary jump relocations in gas?
- From: Andy Lutomirski <luto at amacapital dot net>
- To: "H. Peter Anvin" <hpa at zytor dot com>
- Cc: "H.J. Lu" <hjl dot tools at gmail dot com>, Borislav Petkov <bp at alien8 dot de>, Jan Beulich <JBeulich at suse dot com>, Binutils <binutils at sourceware dot org>, "linux-kernel at vger dot kernel dot org" <linux-kernel at vger dot kernel dot org>
- Date: Wed, 20 May 2015 14:47:10 -0700
- Subject: Re: Avoiding unnecessary jump relocations in gas?
- Authentication-results: sourceware.org; auth=none
- References: <CALCETrUXnXVARO=KD+r0YV1wi2vvXF-41VS++F877HsJs1qz9Q at mail dot gmail dot com> <554B6E0102000078000778D0 at mail dot emea dot novell dot com> <CAMe9rOri61BL=uUgC8FVCs0peGR=KKRh629rOsRtbzMs8N=MrA at mail dot gmail dot com> <CALCETrX35KY8M0JKdoF1CB853AiS8wqH2-uQ976EptU3xf3=Dg at mail dot gmail dot com> <CAMe9rOpOuYY0DffAd21VffSpvzvrkPe2pJxpZtEQX=Djpi_Lgw at mail dot gmail dot com> <CAMe9rOrA2QGEagix2PK=QwwapBWMptr4gxW8t06-HhkodBTVwA at mail dot gmail dot com> <CALCETrVSN7Mt_tRQ1_x=mvYD-ygoCHM+juvi80bhddaUEDDxdA at mail dot gmail dot com> <CAMe9rOqrdRUH9kPU6aO=fmtfdPoua319kvsZgRovEyT37kencQ at mail dot gmail dot com> <555A4628 dot 4060802 at zytor dot com> <CAMe9rOrSP=XW29ae3fkHrFUdjhfvGbB5b5U=EA74wofNC4qEBA at mail dot gmail dot com> <555A4B67 dot 4080201 at zytor dot com> <555A4CCC dot 2010102 at zytor dot com> <CALCETrUQ_uMLEn3O-Vmu0vOm_4qRYxgj8YZOUJE13SDMqQmBPQ at mail dot gmail dot com> <555CF5B7 dot 8080709 at zytor dot com>
On Wed, May 20, 2015 at 1:59 PM, H. Peter Anvin <firstname.lastname@example.org> wrote:
> On 05/20/2015 01:53 PM, Andy Lutomirski wrote:
>> Egads. Now I understand what that code is. I don't like the balign,
>> since this has nothing to do with alignment -- we're creating an array
>> of functions.
> Actually it does... we align to the beginning of each slot. If .balign
> could be something other than a power of 2 that would work, too.
When I see "align", I think that we want to align to a multiple of X
but we don't particularly care which multiple of X. Here we want a
specific address and any other address would be an error.
> I was mostly looking to minimize the amount of gas magic we rely on.
>> Can't we make it explicit?
>> #define EARLY_IDT_HANDLER_STRIDE 9
>> .rept NUM_EXCEPTION_VECTORS
>> . = early_idt_handlers + i * EARLY_IDT_HANDLER_STRIDE
>> .if (EXCEPTION_ERRCODE_MASK >> i) & 1
>> pushl $0 # Dummy error code, to make stack frame uniform
>> pushl $i # 20(%esp) Vector number
>> jmp early_idt_handler
>> i = i + 1
>> gas will error out if we try to move . backwards, so this should be safe.
> If that works too with all the versions of gas we care about, that would
> be fine (and I do appreciate the explicitness.) However, .[b]align is
> something that will have been well exercised in every version of gas, so
> I do feel slightly safer with it.
I have no idea how to easily test my approach on really old binutils
versions, but I'm reasonably confident that assigning to . is common.