[PATCH] D27613: [ELF] - Change how -Ttext/-Tdata/-Tbss works.

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 9 11:26:34 PST 2016


ruiu added inline comments.


================
Comment at: ELF/Driver.cpp:584-588
+  // When user gives -Ttext/-Tdata/-Tbss GNU linkers either set addresses
+  // of corresponding sections or addressed for PT_LOADs. That means we want
+  // to have "text segment" to work with. It includes RO sections as well.
+  if (!Config->SectionStartMap.empty())
+    Config->SingleRoRx = true;
----------------
I do not get the meaning of this code. Can you give me an example?


================
Comment at: ELF/Writer.cpp:1299-1308
+  uint64_t VA = (uint64_t)-1;
+  for (auto I = Config->SectionStartMap.begin();
+       I != Config->SectionStartMap.end(); ++I) {
+    if (VA > I->second)
+      VA = I->second;
+  }
+  uint64_t HeadersSize = getHeaderSize<ELFT>();
----------------
What does this code do? Needs explanation.


================
Comment at: ELF/Writer.cpp:1326
 template <class ELFT> void Writer<ELFT>::assignAddresses() {
-  uintX_t VA = Config->ImageBase + getHeaderSize<ELFT>();
+  uintX_t VA = getVABase<ELFT>() + getHeaderSize<ELFT>();
   uintX_t ThreadBssOffset = 0;
----------------
You shouldn't compute the same value twice. Use the previous result instead.


================
Comment at: ELF/Writer.cpp:1369-1372
+  // We take max value here for case when user set VA of section using -T
+  // below address of headers. We do not align offsets then, that is
+  // consistent with bfd behavior.
+  return std::max<uintX_t>(Off, First->Offset + Sec->Addr - First->Addr);
----------------
This seems too tricky. Is there any better way?


https://reviews.llvm.org/D27613





More information about the llvm-commits mailing list