Skip to content

Commit 5fedfc9

Browse files
committed
Sync .note.gnu.property to PT_GNU_PROPERTY
1 parent 683e41d commit 5fedfc9

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/elf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ typedef struct
585585
#define PT_GNU_EH_FRAME 0x6474e550 /* GCC .eh_frame_hdr segment */
586586
#define PT_GNU_STACK 0x6474e551 /* Indicates stack executability */
587587
#define PT_GNU_RELRO 0x6474e552 /* Read-only after relocation */
588+
#define PT_GNU_PROPERTY 0x6474e553 /* GNU property */
588589
#define PT_LOSUNW 0x6ffffffa
589590
#define PT_SUNWBSS 0x6ffffffa /* Sun Specific segment */
590591
#define PT_SUNWSTACK 0x6ffffffb /* Stack segment */

src/patchelf.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,18 @@ void ElfFile<ElfFileParamNames>::writeReplacedSections(Elf_Off & curOff,
652652
}
653653
}
654654

655+
/* If there is .note.gnu.property section, then the PT_GNU_PROPERTY
656+
segment must be sync'ed with it. */
657+
if (sectionName == ".note.gnu.property") {
658+
for (auto & phdr : phdrs) {
659+
if (rdi(phdr.p_type) == PT_GNU_PROPERTY) {
660+
phdr.p_offset = shdr.sh_offset;
661+
phdr.p_vaddr = phdr.p_paddr = shdr.sh_addr;
662+
phdr.p_filesz = phdr.p_memsz = shdr.sh_size;
663+
}
664+
}
665+
}
666+
655667
curOff += roundUp(i.second.size(), sectionAlignment);
656668
}
657669

0 commit comments

Comments
 (0)