Three more days left before the 2.30 release...

H.J. Lu
Fri Jan 26 16:52:00 GMT 2018

On Fri, Jan 26, 2018 at 8:24 AM, Mark Wielaard <> wrote:
> On Fri, 2018-01-26 at 15:46 +0000, Nick Clifton wrote:
>> > > Could you take a look at the bug and proposed fix for
>> > >
>> > > "Bad alignment and padding of"
>> > >
>> > > This breaks existing code that depends on the normal way GNU ELF notes
>> > Currently only section follows the gABI.  Since they
>> > are placed in a separate note section/segment which contains only
>> > one such note,  it shouldn't be an issue since you don't need to use
>> > alignment to check the next note.  I believe these tools should be
>> > updated to follow gABI without breaking backward compatibility
>> > like what we did in binutils and glibc.
>> Mark - can you confirm/deny this.  If there is only one note in the section
>> does the section alignment matter ?
> It doesn't follow gABI, since with ELFCLASS64 it uses 8-byte alignment
> and padding between the name/data, but 4-byte values for the sizes.
> Which is neither normal GNU ELF note layout, nor gabi ELF note layout.

I assume you refer to

typedef struct {
  unsigned char namesz[4];              /* Size of entry's owner string */
  unsigned char descsz[4];              /* Size of the note descriptor */
  unsigned char type[4];                /* Interpretation of the descriptor */
  char          name[1];                /* Start of the name+desc data */
} Elf_External_Note;

This is very unfortunately that gABI doesn't explicit say what data types
the note header should use.

> I believe binutils ld will not merge ELF NOTE sections or segments that
> have different alignments now. But other tools might try to do that

If they do that,  that is a bug in these tools.

> since normal GNU ELF notes all use the same alignment (some might not
> even have the alignment set), so they won't know they cannot. The

We know some producers set alignment in note header to 0 or 1.  But I
never saw random values.  If they do set alignment in note header to
random values, they should be fixed.

> problem is that even if the notes might be in separate sections or
> segments that code will assume it can read them all and seeing bogus
> data in one they will most likely stop processing any others.

How come when there is only one note?

> I appreciate that H.J. is fixing up various tools to follow this new
> layout. But this feels like a loosing game of whack-a-mole. There is no
> reason to not use the normal GNU ELF note layout (which is also used by
> others). And inventing something new that isn't GNU and isn't really
> gabi after all these years is just asking for trouble.

I just don't believe it.  Please show a couple examples to back up
your claims.


More information about the Binutils mailing list