[lld] r265129 - [ELF] - Move calculation of _end to fixAbsoluteSymbols()

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 1 03:23:32 PDT 2016


Author: grimar
Date: Fri Apr  1 05:23:32 2016
New Revision: 265129

URL: http://llvm.org/viewvc/llvm-project?rev=265129&view=rev
Log:
[ELF] - Move calculation of _end to fixAbsoluteSymbols()

That is consistent with other symbols: _edata, _etext
and can help to avoid duplicate code.

Differential revision: http://reviews.llvm.org/D18655

Modified:
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=265129&r1=265128&r2=265129&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Apr  1 05:23:32 2016
@@ -1424,10 +1424,6 @@ template <class ELFT> void Writer<ELFT>:
   SectionHeaderOff = alignTo(FileOff, sizeof(uintX_t));
   FileSize = SectionHeaderOff + getNumSections() * sizeof(Elf_Shdr);
 
-  // Update "_end" and "end" symbols so that they
-  // point to the end of the data segment.
-  ElfSym<ELFT>::End.st_value = VA;
-
   for (Phdr &PHdr : Phdrs) {
     Elf_Phdr &H = PHdr.H;
     if (PHdr.First) {
@@ -1503,9 +1499,11 @@ template <class ELFT> void Writer<ELFT>:
 
   // _etext is the first location after the last read-only loadable segment.
   // _edata is the first location after the last read-write loadable segment.
+  // _end is the first location after the uninitialized data region.
   for (Phdr &PHdr : Phdrs) {
     if (PHdr.H.p_type != PT_LOAD)
       continue;
+    ElfSym<ELFT>::End.st_value = PHdr.H.p_vaddr + PHdr.H.p_memsz;
     uintX_t Val = PHdr.H.p_vaddr + PHdr.H.p_filesz;
     if (PHdr.H.p_flags & PF_W)
       ElfSym<ELFT>::Edata.st_value = Val;




More information about the llvm-commits mailing list