[PATCH] D49371: [ELF] - Do not produce broken output when amount of sections is > ~65k

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 16 06:08:23 PDT 2018


grimar created this revision.
grimar added a reviewer: ruiu.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

This is https://bugs.llvm.org//show_bug.cgi?id=38119

We produce broken ELF header now when the number of output sections is >=  SHN_LORESERVE (0xff00).

ELF spec says (http://www.sco.com/developers/gabi/2003-12-17/ch4.eheader.html):

> e_shnum:
>  If the number of sections is greater than or equal to SHN_LORESERVE (0xff00), this member has the value zero
>  and the actual number of section header table entries is contained in the sh_size field of the section header at index 0.
>  (Otherwise, the sh_size member of the initial entry contains 0.)
> 
> e_shstrndx
>  If the section name string table section index is greater than or equal to SHN_LORESERVE (0xff00), this member has the
>  value SHN_XINDEX (0xffff) and the actual index of the section name string table section is contained in the sh_link field of
>  the section header at index 0. (Otherwise, the sh_link member of the initial entry contains 0.)

We did not set these fields correctly earlier. The patch fixes the issue.


https://reviews.llvm.org/D49371

Files:
  ELF/Writer.cpp
  test/ELF/relocatable-many-sections.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49371.155657.patch
Type: text/x-patch
Size: 3372 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180716/843f127c/attachment.bin>


More information about the llvm-commits mailing list