[PATCH] define SHT_LLVM_ADDRSIG section rather than error out

Navin P navinp0304@gmail.com
Wed Nov 18 05:34:03 GMT 2020


On Tue, Nov 17, 2020 at 7:49 PM Mark Wielaard <mark@klomp.org> wrote:
>
> Hi Navin,
>
> On Fri, 2020-11-13 at 20:45 +0530, Navin P via Elfutils-devel wrote:
> >  make elflint ignore it rather error as unsupported type. Other tools
> > like
> >  readelf , objdump understand this section.
>
> Is there a specification of this section type?
>
> diff --git a/libelf/elf.h b/libelf/elf.h
> > index 6439c1a4..26420b45 100644
> > --- a/libelf/elf.h
> > +++ b/libelf/elf.h
> > @@ -444,6 +444,7 @@ typedef struct
> >  #define SHT_SYMTAB_SHNDX  18 /* Extended section indeces */
> >  #define SHT_NUM   19 /* Number of defined types.  */
> >  #define SHT_LOOS   0x60000000 /* Start OS-specific.  */
> > +#define SHT_LLVM_ADDRSIG  0x6FFF4C03    /* llvm address sig */
> >  #define SHT_GNU_ATTRIBUTES 0x6ffffff5 /* Object attributes.  */
> >  #define SHT_GNU_HASH   0x6ffffff6 /* GNU-style hash table.  */
> >  #define SHT_GNU_LIBLIST   0x6ffffff7 /* Prelink library list */
>
> elf.h comes from the glibc project.
> We should first try to upstream new constants there
> (glibc-alpha@sourceware.org)
>
> > diff --git a/src/elflint.c b/src/elflint.c
> > index ef3e3732..62663800 100644
> > --- a/src/elflint.c
> > +++ b/src/elflint.c
> > @@ -3905,6 +3905,7 @@ section [%2zu] '%s': size not multiple of entry
> > size\n"),
> >     && shdr->sh_type != SHT_GNU_ATTRIBUTES
> >     && shdr->sh_type != SHT_GNU_LIBLIST
> >     && shdr->sh_type != SHT_CHECKSUM
> > +   && shdr->sh_type != SHT_LLVM_ADDRSIG
> >     && shdr->sh_type != SHT_GNU_verdef
> >     && shdr->sh_type != SHT_GNU_verneed
> >     && shdr->sh_type != SHT_GNU_versym
>
> Note that for various of these SHT_GNU extensions we actually do have
> some extra checks. Do we need to check anything for a section marked
> SHT_LLVM_ADDRSIG?
>
We can do two things here
a) Recognize the section exists but ignore its contents which is what i
do. This needn't be the correct approach.
You may need to check the contents to sht_llvm_addrsig but that is
lot of work after the format has been frozen.
https://www.mail-archive.com/netdev@vger.kernel.org/msg348254.html
readelf output
[22] .llvm_addrsig     LOOS+0xfff4c03  0000000000000000 ...

b) If we don't want to recognize SHT_LLVM_ADDRSIG
you can strip section from object file by objcopy -R .llvm_addrsig size.o
conditionally  based on clang compiler.


More information about the Elfutils-devel mailing list