Skip to content

Commit

Permalink
Sync .note.gnu.property to PT_GNU_PROPERTY
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo98 committed Oct 10, 2022
1 parent 683e41d commit 5fedfc9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ typedef struct
#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */
#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */
#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */
#define PT_GNU_PROPERTY 0x6474e553 /* GNU property */
#define PT_LOSUNW 0x6ffffffa
#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */
Expand Down
12 changes: 12 additions & 0 deletions src/patchelf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,18 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
}
}

/* If there is .note.gnu.property section, then the PT_GNU_PROPERTY
segment must be sync'ed with it. */
if (sectionName == ".note.gnu.property") {
for (auto & phdr : phdrs) {
if (rdi(phdr.p_type) == PT_GNU_PROPERTY) {
phdr.p_offset = shdr.sh_offset;
phdr.p_vaddr = phdr.p_paddr = shdr.sh_addr;
phdr.p_filesz = phdr.p_memsz = shdr.sh_size;
}
}
}

curOff += roundUp(i.second.size(), sectionAlignment);
}

Expand Down

0 comments on commit 5fedfc9

Please sign in to comment.