Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ELF] Change default output section type to SHT_PROGBITS
This fixes an issue where a symbol only section at the start of a PT_LOAD segment, causes incorrect alignment of the file offset for the start of the segment which results in the output of an invalid ELF. SHT_PROGBITS was the default output section type in the past. Differential Revision: https://reviews.llvm.org/D60131 llvm-svn: 358981
- Loading branch information
Showing
7 changed files
with
45 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# REQUIRES: x86 | ||
# RUN: echo '.text; ret; .data; .quad 0' > %t.s | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t.s -o %t.o | ||
# RUN: ld.lld -o %t --script %s %t.o -shared | ||
# RUN: llvm-readobj -elf-output-style=GNU -s -t -l %t | FileCheck %s | ||
|
||
PHDRS { | ||
text PT_LOAD FLAGS(0x5); | ||
data PT_LOAD FLAGS(0x6); | ||
} | ||
|
||
SECTIONS { | ||
. = SIZEOF_HEADERS; | ||
.text : { *(.text) } : text | ||
. = ALIGN(CONSTANT(MAXPAGESIZE)); | ||
foo : { __start_foo = .; *(foo); __end_foo = .; } : data | ||
.data : { *(.data) } | ||
.dynamic : { *(.dynamic) } | ||
} | ||
|
||
## Check that foo, the symbol only section, has the expected aligned address and | ||
## file offset. Also check that the section's symbols and the data segment's | ||
## offset and addresses match. | ||
|
||
# CHECK: Section Headers | ||
# CHECK: foo PROGBITS 0000000000[[ADDR:[0-9a-f]*]] [[ADDR]] | ||
# CHECK-NEXT: .data PROGBITS 0000000000[[ADDR]] [[ADDR]] | ||
|
||
# CHECK: Symbol table | ||
# CHECK: 0000000000[[ADDR]] 0 NOTYPE GLOBAL DEFAULT {{[0-9]+}} __start_foo | ||
# CHECK: 0000000000[[ADDR]] 0 NOTYPE GLOBAL DEFAULT {{[0-9]+}} __end_foo | ||
|
||
# CHECK: Program Headers | ||
# CHECK: LOAD | ||
# CHECK-NEXT: LOAD 0x[[ADDR]] 0x0000000000[[ADDR]] 0x0000000000[[ADDR]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters