[PATCH] D13814: Add support for SHF_MERGE sections
Shankar Easwaran via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 16 12:27:31 PDT 2015
shankare added a subscriber: shankare.
================
Comment at: ELF/InputFiles.cpp:160
@@ -157,1 +159,3 @@
+ else
+ error("bar");
break;
----------------
An appropriate error message might be needed here.
================
Comment at: ELF/InputFiles.cpp:164
@@ -159,2 +163,3 @@
default:
- Sections[I] = new (this->Alloc) InputSection<ELFT>(this, &Sec);
+ if (Sec.sh_flags & SHF_MERGE)
+ Sections[I] = new (this->Alloc) MergeInputSection<ELFT>(this, &Sec);
----------------
Linker can merge across readonly merge sections. You might want to check that section flags do not have write permission.
================
Comment at: ELF/InputSection.cpp:74-75
@@ +73,4 @@
+ return Addend;
+ if (Sym->getType() != STT_SECTION)
+ return Addend;
+
----------------
You can also have a relocation to a local symbol in a merge section. For the local symbol usecase in a merge string section you would need to get the value of the local symbol too.
================
Comment at: ELF/InputSection.cpp:168
@@ +167,3 @@
+ if (Value + EntSize > Data.size())
+ error("zed");
+ Data = Data.slice(Value, EntSize);
----------------
Error message.
================
Comment at: ELF/OutputSections.cpp:479
@@ +478,3 @@
+ if (Offset + EntSize > Data.size())
+ error("zed");
+
----------------
error message.
================
Comment at: ELF/OutputSections.cpp:564
@@ +563,3 @@
+unsigned MergeOutputSection<ELFT>::getOffset(ArrayRef<uint8_t> Val) {
+ StringRef Hack((char *)Val.data(), Val.size());
+ auto I = Offsets.find(Hack);
----------------
Can we change the variable names and error messages to be proper ?
================
Comment at: ELF/OutputSections.cpp:567
@@ +566,3 @@
+ if (I == Offsets.end())
+ error("foo");
+ return I->second;
----------------
error message.
http://reviews.llvm.org/D13814
More information about the llvm-commits
mailing list