1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t 3 4# RUN: ld.lld -o %t.out %t --oformat=binary 5# RUN: od -t x1 -v %t.out | FileCheck %s 6# CHECK: 0000000 90 11 22 7# CHECK-NEXT: 0000003 8 9## Check case when linkerscript is used. 10# RUN: echo "SECTIONS { . = 0x1000; }" > %t.script 11# RUN: ld.lld -o %t2.out --script %t.script %t --oformat binary 12# RUN: od -t x1 -v %t2.out | FileCheck %s 13 14# RUN: echo "SECTIONS { }" > %t.script 15# RUN: ld.lld -o %t2.out --script %t.script %t --oformat binary 16# RUN: od -t x1 -v %t2.out | FileCheck %s 17 18## LMA(.text)=0x100, LMA(.mysec)=0x108. The minimum LMA of all non-empty sections is 0x100. 19## We place an output section at its LMA minus 0x100. 20# RUN: echo 'SECTIONS { .text 0x100 : {*(.text)} .mysec ALIGN(8) : {*(.mysec*)} }' > %talign.lds 21# RUN: ld.lld -T %talign.lds %t --oformat binary -o %talign 22# RUN: od -Ax -t x1 %talign | FileCheck %s --check-prefix=ALIGN --ignore-case 23 24# ALIGN: 000000 90 00 00 00 00 00 00 00 11 22 25# ALIGN-NEXT: 00000a 26 27## The empty section .data is ignored when computing the file size. 28# RUN: echo 'SECTIONS { .text : {*(.text .mysec*)} .data 0x100 : {keep = .;}}' > %tempty.lds 29# RUN: ld.lld -T %tempty.lds %t --oformat binary -o %tempty 30# RUN: od -t x1 %tempty | FileCheck %s 31 32## NOBITS sections are ignored as well. 33## Also test that SIZEOF_HEADERS evaluates to 0. 34# RUN: echo 'SECTIONS { .text : {. += SIZEOF_HEADERS; *(.text .mysec*)} .data 0x100 (NOLOAD) : {BYTE(0)}}' > %tnobits.lds 35# RUN: ld.lld -T %tnobits.lds %t --oformat binary -o %tnobits 36# RUN: od -t x1 %tnobits | FileCheck %s 37 38## FIXME .mysec should be placed at file offset 1. 39## This does not work because for a section without PT_LOAD, we consider LMA = VMA. 40# RUN: echo 'SECTIONS { .text : {*(.text)} .mysec 0x8 : AT(1) {*(.mysec*)} }' > %tlma.lds 41# RUN: ld.lld -T %tlma.lds %t --oformat binary -o %tlma 42# RUN: od -Ax -t x1 %tlma | FileCheck %s --check-prefix=ALIGN --ignore-case 43 44# RUN: not ld.lld -o /dev/null %t --oformat foo 2>&1 \ 45# RUN: | FileCheck %s --check-prefix ERR 46# ERR: unknown --oformat value: foo 47 48# RUN: ld.lld -o /dev/null %t --oformat elf 49# RUN: ld.lld -o /dev/null %t --oformat=elf-foo 50 51.text 52.align 4 53.globl _start 54_start: 55 nop 56 57.section .mysec.1,"ax" 58.byte 0x11 59 60.section .mysec.2,"ax" 61.byte 0x22 62