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# RUN: echo 'SECTIONS { .text : {*(.text .mysec*)} .data 0x100 (NOLOAD) : {BYTE(0)}}' > %tnobits.lds 34# RUN: ld.lld -T %tnobits.lds %t --oformat binary -o %tnobits 35# RUN: od -t x1 %tnobits | FileCheck %s 36 37## FIXME .mysec should be placed at file offset 1. 38## This does not work because for a section without PT_LOAD, we consider LMA = VMA. 39# RUN: echo 'SECTIONS { .text : {*(.text)} .mysec 0x8 : AT(1) {*(.mysec*)} }' > %tlma.lds 40# RUN: ld.lld -T %tlma.lds %t --oformat binary -o %tlma 41# RUN: od -Ax -t x1 %tlma | FileCheck %s --check-prefix=ALIGN --ignore-case 42 43# RUN: not ld.lld -o /dev/null %t --oformat foo 2>&1 \ 44# RUN: | FileCheck %s --check-prefix ERR 45# ERR: unknown --oformat value: foo 46 47# RUN: ld.lld -o /dev/null %t --oformat elf 48# RUN: ld.lld -o /dev/null %t --oformat elf-foo 49 50.text 51.align 4 52.globl _start 53_start: 54 nop 55 56.section .mysec.1,"ax" 57.byte 0x11 58 59.section .mysec.2,"ax" 60.byte 0x22 61