Fix the alignment of PT_PHDR.

We were claiming it was aligned to 8 bytes even on 32 bit files, which
is not the case.

llvm-svn: 260102
This commit is contained in:
Rafael Espindola 2016-02-08 15:33:53 +00:00
parent 529c27f408
commit a64f7d1148
4 changed files with 5 additions and 4 deletions

View File

@ -1187,7 +1187,8 @@ template <class ELFT> void Writer<ELFT>::assignAddresses() {
size_t PhdrSize = sizeof(Elf_Phdr) * Phdrs.size();
// The first phdr entry is PT_PHDR which describes the program header itself.
setPhdr(&Phdrs[0], PT_PHDR, PF_R, FileOff, VA, PhdrSize, /*Align=*/8);
setPhdr(&Phdrs[0], PT_PHDR, PF_R, FileOff, VA, PhdrSize,
/*Align=*/sizeof(uintX_t));
FileOff += PhdrSize;
VA += PhdrSize;

View File

@ -216,7 +216,7 @@ __start:
# CHECK-NEXT: Flags [ (0x4)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: ]
# CHECK-NEXT: Alignment: 8
# CHECK-NEXT: Alignment: 4
# CHECK-NEXT: }
# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_LOAD (0x1)

View File

@ -215,7 +215,7 @@
// CHECK-NEXT: Flags [ (0x4)
// CHECK-NEXT: PF_R (0x4)
// CHECK-NEXT: ]
// CHECK-NEXT: Alignment: 8
// CHECK-NEXT: Alignment: 4
// CHECK-NEXT: }
// CHECK-NEXT: ProgramHeader {
// CHECK-NEXT: Type: PT_LOAD (0x1)

View File

@ -120,7 +120,7 @@ _start:
# CHECK-NEXT: Flags [ (0x4)
# CHECK-NEXT: PF_R (0x4)
# CHECK-NEXT: ]
# CHECK-NEXT: Alignment: 8
# CHECK-NEXT: Alignment: 4
# CHECK-NEXT: }
# CHECK-NEXT: ProgramHeader {
# CHECK-NEXT: Type: PT_LOAD (0x1)