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: ARM long branch stubs: be8


On Monday 23 February 2009, Richard Earnshaw wrote:
> On Mon, 2009-02-23 at 12:40 +0100, Christophe LYON wrote:
> > Hi all,
> >
> > Following our recent discussion, I propose the attached patch to fix
> > big-endian / be8 stubs encoding issues.
> >
> > I am not particularly proud of the way it's now done, but it does the
> > job. In short, the Thumb instructions in the stubs now use 1 entry per
> > instruction (instead of 2 instr per entry), but this implies that the
> > encoding functions know the exact layout of each stub, so it makes
> > maintenance a bit more painful (I added some comments to warn about
> > that).
> >
> > I have added one more test (farcall-thumb-arm-be8).
> >
> > Once this is OK, I'll come back to my original patches to improve
> > PIC/PLT support.
>
> I think the cleanest way of doing this is to encode each entry as a
> tupple -- the bit pattern and a type marker, then we have macros
> THUMB16_INSN() THUMB32_INSN(), ARM_INSN() and DATA_WORD() which are used
> to initialize the arrays.  You then get an instruction block that looks
> like:
>
> #define THUMB16_INSN(X) {X, 1}
> #define THUMB32_INSN(X) {X, 2}
> #define ARM_INSN(X)     {X, 3}
> #define DATA_WORD(X)    {X, 4}

I agree.

You could be even cleverer by having ADDR_ABS/ADDR_PIC relocation-like 
entries, and remove all the stub specific knowledge from the code.

> The encoding is slightly expensive (you only need 2 bits to represent
> the 4 types of data that can exist in the array, which wastes at least
> 30 bits for every instruction in the list, but there aren't that many
> stubs and the risk of errors over having separate arrays for the
> instructions and the map is significantly higher.

This is host data, so I don't think we care about a few bits.
I suspect you'll find the extra space used by the array is less than the code 
required to populate the stubs individually.

Paul


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