@@ -997,9 +997,6 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsExecutable()
997
997
Stop when we reach an irreplacable section (such as one of type
998
998
SHT_PROGBITS). These cannot be moved in virtual address space
999
999
since that would invalidate absolute references to them. */
1000
- assert (lastReplaced + 1 < shdrs.size ()); /* !!! I'm lazy. */
1001
- size_t startOffset = rdi (shdrs.at (lastReplaced + 1 ).sh_offset );
1002
- Elf_Addr startAddr = rdi (shdrs.at (lastReplaced + 1 ).sh_addr );
1003
1000
std::string prevSection;
1004
1001
for (unsigned int i = 1 ; i <= lastReplaced; ++i) {
1005
1002
Elf_Shdr & shdr (shdrs.at (i));
@@ -1010,8 +1007,6 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsExecutable()
1010
1007
if ((rdi (shdr.sh_type ) == SHT_PROGBITS && sectionName != " .interp" )
1011
1008
|| prevSection == " .dynstr" )
1012
1009
{
1013
- startOffset = rdi (shdr.sh_offset );
1014
- startAddr = rdi (shdr.sh_addr );
1015
1010
lastReplaced = i - 1 ;
1016
1011
break ;
1017
1012
}
@@ -1022,6 +1017,13 @@ void ElfFile<ElfFileParamNames>::rewriteSectionsExecutable()
1022
1017
prevSection = std::move (sectionName);
1023
1018
}
1024
1019
1020
+ while (lastReplaced < shdrs.size () && shdrs.at (lastReplaced).sh_type == SHT_NOBITS)
1021
+ ++lastReplaced;
1022
+
1023
+ assert (lastReplaced + 1 < shdrs.size ()); /* !!! I'm lazy. */
1024
+ size_t startOffset = rdi (shdrs.at (lastReplaced + 1 ).sh_offset );
1025
+ Elf_Addr startAddr = rdi (shdrs.at (lastReplaced + 1 ).sh_addr );
1026
+
1025
1027
debug (" first reserved offset/addr is 0x%x/0x%llx\n " ,
1026
1028
startOffset, (unsigned long long ) startAddr);
1027
1029
0 commit comments