This is an archive of the discontinued LLVM Phabricator instance.

ELF: Don't create sections for section header index 0
ClosedPublic

Authored by labath on Dec 17 2018, 12:16 AM.

Details

Summary

The first section header does not define a real section. Instead it is
used for various elf extensions. This patch skips creation of a section
for index 0.

This has one furtunate side-effect, as it allows us to use the section
header index as the Section ID (where 0 is also invalid), and allows us
to get rid of a lot of spurious +1s in the ObjectFileELF code.

Event Timeline

labath created this revision.Dec 17 2018, 12:16 AM
labath retitled this revision from ELF: Don't create sections for section 0 to ELF: Don't create sections for section header index 0.Dec 17 2018, 12:23 AM
clayborg accepted this revision.Dec 17 2018, 9:00 AM

Looks good. See inline comment and fix if you agree.

source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
1993

Should we rename "section_idx" to "shndx" to make sure people know it is not a section index, but the ELF version of it?

This revision is now accepted and ready to land.Dec 17 2018, 9:00 AM
labath marked an inline comment as done.Dec 18 2018, 7:57 AM
This revision was automatically updated to reflect the committed changes.