This fixes https://bugs.llvm.org/show_bug.cgi?id=41461
However I have problem with test case, which requires 19MB binary file. Any help is appreciated.
Differential D60555
[llvm-objcopy] Fill .symtab_shndx section correctly evgeny777 on Apr 11 2019, 1:33 AM. Authored by
Details This fixes https://bugs.llvm.org/show_bug.cgi?id=41461 However I have problem with test case, which requires 19MB binary file. Any help is appreciated.
Diff Detail
Event TimelineComment Actions Test case?
Comment Actions
Have you seen bug description?
Comment Actions Sorry, I skipped over that somehow (I think I jumped straight from the bug). We already have at least one test that uses many sections (see many-sections.test). That unzips a pre-built object to achieve this. One option might be to update that object file (and possibly the test), if it can satisfy the prerequisites you need. Comment Actions Could we use llvm-mc and some loop macros to generate a binary with the required amount of sections? Comment Actions LGTM. Good tip, thanks. It's probably worth bearing in mind in case we have any more tests along these lines that the existing pre-canned binary can't be used for.
Comment Actions
Are you sure it's a bug? According to sources it looks like some extension to original readelf output: // Find if: // Processor specific if (SectionIndex >= ELF::SHN_LOPROC && SectionIndex <= ELF::SHN_HIPROC) return std::string("PRC[0x") + to_string(format_hex_no_prefix(SectionIndex, 4)) + "]"; // OS specific if (SectionIndex >= ELF::SHN_LOOS && SectionIndex <= ELF::SHN_HIOS) return std::string("OS[0x") + to_string(format_hex_no_prefix(SectionIndex, 4)) + "]"; // Architecture reserved: if (SectionIndex >= ELF::SHN_LORESERVE && SectionIndex <= ELF::SHN_HIRESERVE) return std::string("RSV[0x") + to_string(format_hex_no_prefix(SectionIndex, 4)) + "]"; Anyway I'll switch to llvm-readobj in the test Comment Actions Yes, it's a bug. Where the original st_shndx field is between SHN_LORESERVE and SHN_HIRESERVE (and not SHN_XINDEX), it should be decorated in this way. In all other cases it shouldn't be. It's a little complicated to explain in detail, but I'll do my best. If we look at the section header table, there are sections with index 0xff00, 0xff01, etc. Thus when we generally refer to sections with index 0xff00 etc we are talking about those sections. The symbol st_shndx field (i.e. the field indicating the symbol's section) however is only 16 bits, and the upper few values are reserved for various purposes. The SHN_XINDEX value (0xffff) in this context means look up the section index in the SHT_SYMTAB_SHNDX section instead. Other values in this range have other meanings (e.g. absolute and common symbols). If the real section index for the symbol's section is >= SHN_LORESERVE, it is impossible to represent it in directly in st_shndx, so it will be SHN_XINDEX. llvm-readelf should print the real section index in the section index column, or a special interpretation where the value in the st_shndx field is a reserved value, such as SHN_ABS. The code in llvm-readelf should only do that special interpretation for the raw st_shndx field value, not the interpreted value (i.e. the value after lookups in SHT_SYMTAB_SHNDX) which I think is what it is doing (though I haven't looked in depth at the code yet to be 100% sure).
|
Let's stick to SectionIndexTable =! nullptr given line 501