brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · a3780a6 Raw
75 lines · plain
1# REQUIRES: x862# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t3 4# RUN: ld.lld -o %t.out %t --oformat=binary5# RUN: od -t x1 -v %t.out | FileCheck %s6# CHECK:      0000000 90 11 227# CHECK-NEXT: 00000038 9## OUTPUT_FORMAT(binary) selects the binary format as well.10# RUN: echo "OUTPUT_FORMAT(binary)" > %t.script11# RUN: ld.lld -o %t2.out -T %t.script %t12# RUN: od -t x1 -v %t2.out | FileCheck %s13## More OUTPUT_FORMAT commands are ignored.14# RUN: echo "OUTPUT_FORMAT("binary")OUTPUT_FORMAT(elf64-x86-64)" > %t.script15# RUN: ld.lld -o %t2.out -T %t.script %t16# RUN: od -t x1 -v %t2.out | FileCheck %s17 18## --oformat=binary overrides an ELF OUTPUT_FORMAT.19# RUN: echo "OUTPUT_FORMAT(elf64-x86-64) SECTIONS { . = 0x1000; }" > %t.script20# RUN: ld.lld -o %t2.out --script %t.script %t --oformat binary21# RUN: od -t x1 -v %t2.out | FileCheck %s22 23# RUN: echo "SECTIONS { }" > %t.script24# RUN: ld.lld -o %t2.out --script %t.script %t --oformat binary25# RUN: od -t x1 -v %t2.out | FileCheck %s26 27## LMA(.text)=0x100, LMA(.mysec)=0x108. The minimum LMA of all non-empty sections is 0x100.28## We place an output section at its LMA minus 0x100.29# RUN: echo 'SECTIONS { .text 0x100 : {*(.text)} .mysec ALIGN(8) : {*(.mysec*)} }' > %talign.lds30# RUN: ld.lld -T %talign.lds %t --oformat binary -o %talign31# RUN: od -Ax -t x1 %talign | FileCheck %s --check-prefix=ALIGN --ignore-case32 33# ALIGN:      000000 90 00 00 00 00 00 00 00 11 2234# ALIGN-NEXT: 00000a35 36## The empty section .data is ignored when computing the file size.37# RUN: echo 'SECTIONS { .text : {*(.text .mysec*)} .data 0x100 : {keep = .;}}' > %tempty.lds38# RUN: ld.lld -T %tempty.lds %t --oformat binary -o %tempty39# RUN: od -t x1 %tempty | FileCheck %s40 41## NOBITS sections are ignored as well.42## Also test that SIZEOF_HEADERS evaluates to 0.43# RUN: echo 'SECTIONS { .text : {. += SIZEOF_HEADERS; *(.text .mysec*)} .data 0x100 (NOLOAD) : {BYTE(0)}}' > %tnobits.lds44# RUN: ld.lld -T %tnobits.lds %t --oformat binary -o %tnobits45# RUN: od -t x1 %tnobits | FileCheck %s46 47## FIXME .mysec should be placed at file offset 1.48## This does not work because for a section without PT_LOAD, we consider LMA = VMA.49# RUN: echo 'SECTIONS { .text : {*(.text)} .mysec 0x8 : AT(1) {*(.mysec*)} }' > %tlma.lds50# RUN: ld.lld -T %tlma.lds %t --oformat binary -o %tlma51# RUN: od -Ax -t x1 %tlma | FileCheck %s --check-prefix=ALIGN --ignore-case52 53# RUN: not ld.lld -o /dev/null %t --oformat foo 2>&1 \54# RUN:   | FileCheck %s --check-prefix ERR55# ERR: unknown --oformat value: foo56 57# RUN: echo "OUTPUT_FORMAT(binary-freebsd)" > %t.script58# RUN: not ld.lld -T %t.script %t -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR259# ERR2: error: {{.*}}.script:1: unknown output format name: binary-freebsd60 61# RUN: ld.lld -o /dev/null %t --oformat elf62# RUN: ld.lld -o /dev/null %t --oformat=elf-foo63 64.text65.align 466.globl _start67_start:68 nop69 70.section        .mysec.1,"ax"71.byte   0x1172 73.section        .mysec.2,"ax"74.byte   0x2275