Index: test/ELF/linkerscript/overlapping-sections.s =================================================================== --- test/ELF/linkerscript/overlapping-sections.s +++ test/ELF/linkerscript/overlapping-sections.s @@ -1,61 +1,5 @@ -# TODO: maybe this should be converted to an x86 test to get more buildbot coverage -# REQUIRES: mips -# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t.o - -# RUN: echo "SECTIONS { \ -# RUN: .sec1 0x8000 : { sec1_start = .; *(.first_sec) sec1_end = .;} \ -# RUN: .sec2 0x8800 : { sec2_start = .; *(.second_sec) sec2_end = .;} \ -# RUN: }" > %t.script -# RUN: ld.lld -o %t.so --script %t.script %t.o -shared -# RUN: llvm-readobj -sections -program-headers %t.so | FileCheck %s -check-prefix GOOD - -# GOOD: Name: .sec1 -# GOOD-NEXT: Type: SHT_PROGBITS (0x1) -# GOOD-NEXT: Flags [ (0x3) -# GOOD-NEXT: SHF_ALLOC (0x2) -# GOOD-NEXT: SHF_WRITE (0x1) -# GOOD-NEXT: ] -# GOOD-NEXT: Address: 0x8000 -# GOOD-NEXT: Offset: 0x18000 -# GOOD-NEXT: Size: 256 - -# GOOD: Name: .sec2 -# GOOD-NEXT: Type: SHT_PROGBITS (0x1) -# GOOD-NEXT: Flags [ (0x3) -# GOOD-NEXT: SHF_ALLOC (0x2) -# GOOD-NEXT: SHF_WRITE (0x1) -# GOOD-NEXT: ] -# GOOD-NEXT: Address: 0x8800 -# GOOD-NEXT: Offset: 0x18800 -# GOOD-NEXT: Size: 256 - -# GOOD: ProgramHeaders [ -# GOOD-NEXT: ProgramHeader { -# GOOD-NEXT: Type: PT_LOAD (0x1) -# GOOD-NEXT: Offset: 0x10000 -# GOOD-NEXT: VirtualAddress: 0x0 -# GOOD-NEXT: PhysicalAddress: 0x0 -# GOOD-NEXT: FileSize: 481 -# GOOD-NEXT: MemSize: 481 -# GOOD-NEXT: Flags [ (0x5) -# GOOD-NEXT: PF_R (0x4) -# GOOD-NEXT: PF_X (0x1) -# GOOD-NEXT: ] -# GOOD-NEXT: Alignment: 65536 -# GOOD-NEXT: } -# GOOD-NEXT: ProgramHeader { -# GOOD-NEXT: Type: PT_LOAD (0x1) -# GOOD-NEXT: Offset: 0x18000 -# GOOD-NEXT: VirtualAddress: 0x8000 -# GOOD-NEXT: PhysicalAddress: 0x8000 -# GOOD-NEXT: FileSize: 2320 -# GOOD-NEXT: MemSize: 2320 -# GOOD-NEXT: Flags [ (0x6) -# GOOD-NEXT: PF_R (0x4) -# GOOD-NEXT: PF_W (0x2) -# GOOD-NEXT: ] -# GOOD-NEXT: Alignment: 65536 -# GOOD-NEXT: } +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o # RUN: echo "SECTIONS { \ # RUN: .sec1 0x8000 : AT(0x8000) { sec1_start = .; *(.first_sec) sec1_end = .;} \ @@ -75,17 +19,16 @@ # overlaps with where .sec1 is loaded: # RUN: llvm-readobj -sections -program-headers -elf-output-style=GNU %t.so | FileCheck %s -check-prefix BAD-LMA # BAD-LMA-LABEL: Section Headers: -# BAD-LMA: .sec1 PROGBITS 0000000000008000 018000 000100 00 WA 0 0 1 -# BAD-LMA: .sec2 PROGBITS 0000000000008800 018800 000100 00 WA 0 0 1 +# BAD-LMA: .sec1 PROGBITS 0000000000008000 002000 000100 00 WA 0 0 1 +# BAD-LMA: .sec2 PROGBITS 0000000000008800 002800 000100 00 WA 0 0 1 # BAD-LMA-LABEL: Program Headers: # BAD-LMA-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align -# BAD-LMA-NEXT: LOAD 0x010000 0x0000000000000000 0x0000000000000000 0x0001e1 0x0001e1 R E 0x10000 -# BAD-LMA-NEXT: LOAD 0x018000 0x0000000000008000 0x0000000000008000 0x000100 0x000100 RW 0x10000 -# BAD-LMA-NEXT: LOAD 0x018800 0x0000000000008800 0x0000000000008080 0x000110 0x000110 RW 0x10000 +# BAD-LMA-NEXT: LOAD 0x001000 0x0000000000000000 0x0000000000000000 0x0000fd 0x0000fd R E 0x1000 +# BAD-LMA-NEXT: LOAD 0x002000 0x0000000000008000 0x0000000000008000 0x000100 0x000100 RW 0x1000 +# BAD-LMA-NEXT: LOAD 0x002800 0x0000000000008800 0x0000000000008080 0x000170 0x000170 RW 0x1000 # BAD-LMA-LABEL: Section to Segment mapping: # BAD-LMA: 01 .sec1 -# BAD-LMA: 02 .sec2 .data .got - +# BAD-LMA: 02 .sec2 .dynamic # Now try a script where the virtual memory addresses overlap but ensure that the # load addresses don't: @@ -102,16 +45,16 @@ # RUN: ld.lld -o %t.so --script %t-vaddr.script %t.o -shared --noinhibit-exec # RUN: llvm-readobj -sections -program-headers -elf-output-style=GNU %t.so | FileCheck %s -check-prefix BAD-VADDR # BAD-VADDR-LABEL: Section Headers: -# BAD-VADDR: .sec1 PROGBITS 0000000000008000 018000 000100 00 WA 0 0 1 -# BAD-VADDR: .sec2 PROGBITS 0000000000008020 028020 000100 00 WA 0 0 1 +# BAD-VADDR: .sec1 PROGBITS 0000000000008000 002000 000100 00 WA 0 0 1 +# BAD-VADDR: .sec2 PROGBITS 0000000000008020 003020 000100 00 WA 0 0 1 # BAD-VADDR-LABEL: Program Headers: # BAD-VADDR-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align -# BAD-VADDR-NEXT: LOAD 0x010000 0x0000000000000000 0x0000000000000000 0x0001e1 0x0001e1 R E 0x10000 -# BAD-VADDR-NEXT: LOAD 0x018000 0x0000000000008000 0x0000000000008000 0x000100 0x000100 RW 0x10000 -# BAD-VADDR-NEXT: LOAD 0x028020 0x0000000000008020 0x0000000000008800 0x000110 0x000110 RW 0x10000 +# BAD-VADDR-NEXT: LOAD 0x001000 0x0000000000000000 0x0000000000000000 0x0000fd 0x0000fd R E 0x1000 +# BAD-VADDR-NEXT: LOAD 0x002000 0x0000000000008000 0x0000000000008000 0x000100 0x000100 RW 0x1000 +# BAD-VADDR-NEXT: LOAD 0x003020 0x0000000000008020 0x0000000000008800 0x000170 0x000170 RW 0x1000 # BAD-VADDR-LABEL: Section to Segment mapping: # BAD-VADDR: 01 .sec1 -# BAD-VADDR: 02 .sec2 .data .got +# BAD-VADDR: 02 .sec2 .dynamic # Finally check the case where both LMA and vaddr overlap @@ -123,8 +66,8 @@ # RUN: not ld.lld -o %t.so --script %t-both-overlap.script %t.o -shared 2>&1 | FileCheck %s -check-prefix BOTH-OVERLAP-ERR # BOTH-OVERLAP-ERR: error: section .sec1 file range overlaps with .sec2 -# BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x18000, 0x180FF] -# BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x18040, 0x1813F] +# BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x2000, 0x20FF] +# BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x2040, 0x213F] # BOTH-OVERLAP-ERR: error: section .sec1 virtual address range overlaps with .sec2 # BOTH-OVERLAP-ERR-NEXT: >>> .sec1 range is [0x8000, 0x80FF] # BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8040, 0x813F] @@ -133,7 +76,7 @@ # BOTH-OVERLAP-ERR-NEXT: >>> .sec2 range is [0x8040, 0x813F] # RUN: ld.lld -o %t.so --script %t-both-overlap.script %t.o -shared --noinhibit-exec -# Note: I case everything overlaps we create a binary with overlapping file +# Note: In case everything overlaps we create a binary with overlapping file # offsets. ld.bfd seems to place .sec1 to file offset 18000 and .sec2 # at 18100 so that only virtual addr and LMA overlap # However, in order to create such a broken binary the user has to ignore a @@ -141,24 +84,23 @@ # RUN: llvm-objdump -s %t.so | FileCheck %s -check-prefix BROKEN-OUTPUT-FILE # BROKEN-OUTPUT-FILE-LABEL: Contents of section .sec1: -# BROKEN-OUTPUT-FILE-NEXT: 8000 01010101 01010101 01010101 01010101 ................ -# BROKEN-OUTPUT-FILE-NEXT: 8010 01010101 01010101 01010101 01010101 ................ -# BROKEN-OUTPUT-FILE-NEXT: 8020 01010101 01010101 01010101 01010101 ................ -# BROKEN-OUTPUT-FILE-NEXT: 8030 01010101 01010101 01010101 01010101 ................ +# BROKEN-OUTPUT-FILE-NEXT: 8000 01010101 01010101 01010101 01010101 +# BROKEN-OUTPUT-FILE-NEXT: 8010 01010101 01010101 01010101 01010101 +# BROKEN-OUTPUT-FILE-NEXT: 8020 01010101 01010101 01010101 01010101 +# BROKEN-OUTPUT-FILE-NEXT: 8030 01010101 01010101 01010101 01010101 # Starting here the contents of .sec2 overwrites .sec1: -# BROKEN-OUTPUT-FILE-NEXT: 8040 02020202 02020202 02020202 02020202 ................ +# BROKEN-OUTPUT-FILE-NEXT: 8040 02020202 02020202 02020202 02020202 # RUN: llvm-readobj -sections -program-headers -elf-output-style=GNU %t.so | FileCheck %s -check-prefix BAD-BOTH # BAD-BOTH-LABEL: Section Headers: -# BAD-BOTH: .sec1 PROGBITS 0000000000008000 018000 000100 00 WA 0 0 1 -# BAD-BOTH: .sec2 PROGBITS 0000000000008040 018040 000100 00 WA 0 0 1 +# BAD-BOTH: .sec1 PROGBITS 0000000000008000 002000 000100 00 WA 0 0 1 +# BAD-BOTH: .sec2 PROGBITS 0000000000008040 002040 000100 00 WA 0 0 1 # BAD-BOTH-LABEL: Program Headers: # BAD-BOTH-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align -# BAD-BOTH-NEXT: LOAD 0x010000 0x0000000000000000 0x0000000000000000 0x0001e1 0x0001e1 R E 0x10000 -# BAD-BOTH-NEXT: LOAD 0x018000 0x0000000000008000 0x0000000000008000 0x000150 0x000150 RW 0x10000 +# BAD-BOTH-NEXT: LOAD 0x001000 0x0000000000000000 0x0000000000000000 0x0000fd 0x0000fd R E 0x1000 +# BAD-BOTH-NEXT: LOAD 0x002000 0x0000000000008000 0x0000000000008000 0x0001b0 0x0001b0 RW 0x1000 # BAD-BOTH-LABEL: Section to Segment mapping: -# BAD-BOTH: 01 .sec1 .sec2 .data .got - +# BAD-BOTH: 01 .sec1 .sec2 .dynamic .section .first_sec,"aw",@progbits .rept 0x100