[PATCH] D102296: [ELF] getRelocatedSection: allow allocatable section in non-relocatable file
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 12 23:28:49 PDT 2021
Amir created this revision.
Amir added reviewers: maksfb, rafaelauler.
Amir published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D102296
Files:
llvm/include/llvm/Object/ELFObjectFile.h
Index: llvm/include/llvm/Object/ELFObjectFile.h
===================================================================
--- llvm/include/llvm/Object/ELFObjectFile.h
+++ llvm/include/llvm/Object/ELFObjectFile.h
@@ -968,9 +968,6 @@
template <class ELFT>
Expected<section_iterator>
ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
- if (EF.getHeader().e_type != ELF::ET_REL)
- return section_end();
-
const Elf_Shdr *EShdr = getSection(Sec);
uintX_t Type = EShdr->sh_type;
if (Type != ELF::SHT_REL && Type != ELF::SHT_RELA)
@@ -979,6 +976,9 @@
Expected<const Elf_Shdr *> SecOrErr = EF.getSection(EShdr->sh_info);
if (!SecOrErr)
return SecOrErr.takeError();
+ if (EF.getHeader().e_type != ELF::ET_REL &&
+ !((*SecOrErr)->sh_flags & ELF::SHF_ALLOC))
+ return section_end();
return section_iterator(SectionRef(toDRI(*SecOrErr), this));
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102296.344618.patch
Type: text/x-patch
Size: 887 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210513/835efacd/attachment.bin>
More information about the llvm-commits
mailing list