Created
January 24, 2019 01:04
-
-
Save rui314/dc6d771f2fd9d4cb9f65ef6a970488b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp | |
index e35e85dba9b2..128f6a02a4b0 100644 | |
--- a/lld/ELF/InputFiles.cpp | |
+++ b/lld/ELF/InputFiles.cpp | |
@@ -444,7 +444,19 @@ void ObjFile<ELFT>::initializeSections( | |
// We only support GRP_COMDAT type of group. Get the all entries of the | |
// section here to let getShtGroupEntries to check the type early for us. | |
- ArrayRef<Elf_Word> Entries = getShtGroupEntries(Sec); | |
+ ArrayRef<Elf_Word> Entries = | |
+ CHECK(Obj.template getSectionContentsAsArray<Elf_Word>(&Sec), this); | |
+ if (Entries.empty()) | |
+ fatal(toString(this) + ": empty SHT_GROUP"); | |
+ | |
+ // The first word of a SHT_GROUP section contains flags. Currently, | |
+ // the standard defines only "GRP_COMDAT" flag for the COMDAT group. | |
+ // An group with the empty flag doesn't define anything; such sections | |
+ // are just skipped. | |
+ if (Entries[0] == 0) | |
+ continue; | |
+ if (Entries[0] != GRP_COMDAT) | |
+ fatal(toString(this) + ": unsupported SHT_GROUP format"); | |
// If it is a new section group, we want to keep group members. | |
// Group leader sections, which contain indices of group members, are | |
@@ -458,7 +470,7 @@ void ObjFile<ELFT>::initializeSections( | |
} | |
// Otherwise, discard group members. | |
- for (uint32_t SecIndex : Entries) { | |
+ for (uint32_t SecIndex : Entries.slice(1)) { | |
if (SecIndex >= Size) | |
fatal(toString(this) + | |
": invalid section index in group: " + Twine(SecIndex)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment