1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=x86_64-linux %s -o %t.o 3# RUN: echo "SECTIONS { .data 0x4000 : {*(.data)} .dynsym 0x2000 : {*(.dynsym)} .dynstr : {*(.dynstr)} }" > %t.script 4# RUN: ld.lld --hash-style=sysv -o %t.so --script %t.script %t.o -shared 5# RUN: llvm-objdump --section-headers %t.so | FileCheck %s 6 7# Note: how the layout is done: 8# we need to layout 2 segments, each contains sections: 9# seg1: .data .dynamic 10# seg2: .dynsym .dynstr .text .hash 11# for each segment, we start from the first section, regardless 12# whether it is an orphan or not (sections that are not listed in the 13# linkerscript are orphans): 14# for seg1, we assign address: .data(0x4000), .dynamic(0x4008) 15# for seg2, we assign address: .dynsym(0x2000), .dynstr(0x2018) ... 16# .dynsym is not an orphan, so we take address from script, we assign 17# .dynstr current address cursor, which is the end # of .dynsym and so 18# on for later sections. 19 20# Also note, it is absolutely *illegal* to have section addresses of 21# the same segment in none-increasing order, authors of linker scripts 22# must take responsibility to make sure this does not happen. 23 24# CHECK: Sections: 25# CHECK-NEXT: Idx Name Size VMA Type 26# CHECK-NEXT: 0 00000000 0000000000000000 27# CHECK-NEXT: 1 .dynamic 00000060 0000000000000000 28# CHECK-NEXT: 2 .data 00000008 0000000000004000 29# CHECK-NEXT: 3 .dynsym 00000018 0000000000002000 30# CHECK-NEXT: 4 .dynstr 00000001 0000000000002018 31# CHECK-NEXT: 5 .hash 00000010 000000000000201c 32# CHECK-NEXT: 6 .text 00000008 000000000000202c 33 34.quad 0 35.data 36.quad 0 37 38