Fangrui Song 07e2300a8c [ELF,test] Specify image base to make -Ttext/--section-start tests less sensitive
Many tests specify -Ttext, -Tdata, or --section-start without SECTIONS
commands. When the specified address is lower than the image base,

* In the default --ro-segment case, there will be a read-only PT_LOAD segment covering ELF header/program headers, which may cover no section (as many tests omit .rodata). This appears unusual and has non-ascending p_vaddr.
* In the --no-rosegment case, an `error: output file too large` occurs.

We will add a diagnostic (#140187) and possibly change layout. Add
--image-base to make these tests less sensitive.
2025-05-16 23:57:44 -07:00

24 lines
815 B
ArmAsm

# REQUIRES: x86
# Verify that .rodata is aligned to a 8 byte boundary.
# RUN: llvm-mc -filetype=obj -triple=i386 %s -o %t.o
# RUN: ld.lld %t.o -o %t.exe -n --image-base=0 -Ttext 0
# RUN: llvm-readelf --section-headers %t.exe | FileCheck %s
# CHECK: [ 0] NULL 00000000 000000 000000 00 0 0 0
# CHECK: [ 1] .text PROGBITS 00000000 000094 000001 00 AX 0 0 4
# CHECK: [ 2] .rodata PROGBITS 00000008 000098 000008 00 A 0 0 8
# CHECK: [ 3] .comment PROGBITS 00000000 0000a0 000008 01 MS 0 0 1
# CHECK: [ 4] .symtab SYMTAB 00000000 0000a8 000020 10 6 1 4
# CHECK: [ 5] .shstrtab STRTAB 00000000 0000c8 000032 00 0 0 1
# CHECK: [ 6] .strtab STRTAB 00000000 0000fa 000008 00 0 0 1
.globl _start
.text
_start:
ret
.rodata
.align 8
.quad 42