brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.3 KiB · 8c2ccbd Raw
92 lines · plain
1# REQUIRES: x862# RUN: rm -rf %t && split-file %s %t3# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t/a.s -o %t/a.o4# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t/b.s -o %t/b.o5# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t/c.s -o %t/c.o6# RUN: ld.lld %t/a.o -o %t/a7# RUN: llvm-objdump -t --section-headers %t/a | FileCheck %s8 9## This checks that:10## 1) Address of _etext is the first location after the last read-only loadable segment.11## 2) Address of _edata points to the end of the last non SHT_NOBITS section.12##    That is how gold/bfd do. At the same time specs says: "If the address of _edata is13##    greater than the address of _etext, the address of _end is same as the address14##    of _edata." (https://docs.oracle.com/cd/E53394_01/html/E54766/u-etext-3c.html).15## 3) Address of _end is different from _edata because of 2.16## 4) Addresses of _edata == edata, _end == end and _etext == etext.17# CHECK:      Sections:18# CHECK-NEXT:  Idx Name          Size     VMA              Type19# CHECK-NEXT:    0               00000000 000000000000000020# CHECK-NEXT:    1 .text         00000001 0000000000201158 TEXT21# CHECK-NEXT:    2 .data         00000002 0000000000202159 DATA22# CHECK-NEXT:    3 .bss          00000006 000000000020215c BSS23# CHECK:      SYMBOL TABLE:24# CHECK-NEXT:  000000000020215b g       .data 0000000000000000 _edata25# CHECK-NEXT:  0000000000202162 g       .bss  0000000000000000 _end26# CHECK-NEXT:  0000000000201159 g       .text 0000000000000000 _etext27# CHECK-NEXT:  0000000000201158 g       .text 0000000000000000 _start28# CHECK-NEXT:  000000000020215b g       .data 0000000000000000 edata29# CHECK-NEXT:  0000000000202162 g       .bss  0000000000000000 end30# CHECK-NEXT:  0000000000201159 g       .text 0000000000000000 etext31 32# RUN: ld.lld -r %t/a.o -o %t/a.ro33# RUN: llvm-objdump -t %t/a.ro | FileCheck %s --check-prefix=RELOCATABLE34# RELOCATABLE:       0000000000000000 *UND* 0000000000000000 _edata35# RELOCATABLE-NEXT:  0000000000000000 *UND* 0000000000000000 _end36# RELOCATABLE-NEXT:  0000000000000000 *UND* 0000000000000000 _etext37 38## If a relocatable object file defines non-reserved identifiers (by C and C++)39## edata/end/etext, don't redefine them. Note: GNU ld redefines the reserved40## _edata while we don't for simplicity.41# RUN: ld.lld %t/b.o -o %t/b42# RUN: llvm-objdump -t %t/b | FileCheck %s --check-prefix=CHECK243# RUN: ld.lld %t/c.o -o %t/c44# RUN: llvm-objdump -t %t/c | FileCheck %s --check-prefix=CHECK245## PROVIDE does not redefine defined symbols, even if COMMON.46# RUN: ld.lld %t/c.o %t/lds -o %t/c47# RUN: llvm-objdump -t %t/c | FileCheck %s --check-prefix=CHECK248 49# CHECK2:       [[#%x,]] g     O .bss   0000000000000001 _edata50# CHECK2-NEXT:  [[#%x,]] g     O .bss   0000000000000001 edata51# CHECK2-NEXT:  [[#%x,]] g     O .bss   0000000000000001 end52# CHECK2-NEXT:  [[#%x,]] g     O .bss   0000000000000001 etext53 54#--- a.s55.global _edata,_end,_etext,_start,edata,end,etext56.text57_start:58  nop59.data60  .word 161.bss62  .align 463  .space 664 65#--- b.s66.bss67.macro def x68  .globl \x69  .type \x, @object70  \x: .byte 071  .size \x, 172.endm73def _edata74def edata75def end76def etext77 78#--- c.s79.comm _edata,1,180.comm edata,1,181.comm end,1,182.comm etext,1,183 84#--- lds85SECTIONS {86  .text : { *(.text) }87 88  PROVIDE(etext = .);89  PROVIDE(edata = .);90  PROVIDE(end = .);91}92