brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 2f990e0 Raw
50 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64-linux %s -o %t.o3# RUN: echo "SECTIONS { .data 0x4000 : {*(.data)} .dynsym 0x2000 : {*(.dynsym)} .dynstr : {*(.dynstr)} }" > %t.script4# RUN: ld.lld --hash-style=sysv -o %t.so --script %t.script %t.o -shared5# RUN: llvm-objdump --section-headers %t.so | FileCheck %s6 7# Note: how the layout is done:8#  we need to layout 2 segments, each contains sections:9#    seg1: .data .dynamic10#    seg2: .dynsym .dynstr .text .hash11# for each segment, we start from the first section, regardless12# whether it is an orphan or not (sections that are not listed in the13# 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 assign17# .dynstr current address cursor, which is the end # of .dynsym and so18# on for later sections.19 20# Also note, it is absolutely *illegal* to have section addresses of21# the same segment in none-increasing order, authors of linker scripts22# must take responsibility to make sure this does not happen.23 24# CHECK:      Sections:25# CHECK-NEXT: Idx Name          Size     VMA              Type26# CHECK-NEXT:   0               00000000 000000000000000027# CHECK-NEXT:   1 .dynamic      00000060 000000000000000028# CHECK-NEXT:   2 .data         00000008 000000000000400029# CHECK-NEXT:   3 .dynsym       00000018 000000000000200030# CHECK-NEXT:   4 .dynstr       00000001 000000000000201831# CHECK-NEXT:   5 .hash         00000010 000000000000201c32# CHECK-NEXT:   6 .text         00000008 000000000000202c33 34# RUN: ld.lld -e 0 -o %t --script %t.script %t.o --fatal-warnings35# RUN: llvm-readelf -Sl %t | FileCheck %s --check-prefix=CHECK136 37# CHECK1:       Name              Type            Address          Off    Size   ES Flg Lk Inf Al38# CHECK1-NEXT:                    NULL            0000000000000000 000000 000000 00      0   0  039# CHECK1-NEXT:  .text             PROGBITS        0000000000000000 001000 000008 00  AX  0   0  440# CHECK1-NEXT:  .data             PROGBITS        0000000000004000 002000 000008 00  WA  0   0  141# CHECK1:     Program Headers:42# CHECK1-NEXT:  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align43# CHECK1-NEXT:  LOAD           0x001000 0x0000000000000000 0x0000000000000000 0x000008 0x000008 R E 0x100044# CHECK1-NEXT:  LOAD           0x002000 0x0000000000004000 0x0000000000004000 0x000008 0x000008 RW  0x100045 46.quad 047.data48.quad 049 50