xref: /llvm-project/lld/test/ELF/build-id.s (revision 1d96e4bc2d09bc085e7c1b303d930684756b94a7)
1# REQUIRES: x86
2
3# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
4
5# RUN: ld.lld --build-id %t -o %t2
6# RUN: llvm-readobj -S %t2 | FileCheck -check-prefix=ALIGN %s
7
8# RUN: ld.lld --build-id %t -o %t2
9# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SHA1 %s
10# RUN: ld.lld --build-id %t -o %t2 --threads=1
11# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SHA1 %s
12
13# RUN: ld.lld --build-id=fast %t -o %t2
14# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=FAST %s
15
16# RUN: ld.lld --build-id=md5 %t -o %t2
17# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=MD5 %s
18# RUN: ld.lld --build-id=md5 %t -o %t2 --threads=1
19# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=MD5 %s
20
21# RUN: ld.lld --build-id=sha1 %t -o %t2
22# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SHA1 %s
23# RUN: ld.lld --build-id=sha1 %t -o %t2 --threads=1
24# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SHA1 %s
25
26# RUN: ld.lld --build-id=tree %t -o %t2
27# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SHA1 %s
28# RUN: ld.lld --build-id=tree %t -o %t2 --threads=1
29# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SHA1 %s
30
31# RUN: ld.lld --build-id=uuid %t -o %t2
32# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=UUID %s
33
34# RUN: ld.lld --build-id=0x12345678 %t -o %t2
35# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=HEX %s
36
37# RUN: ld.lld %t -o %t2
38# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=NONE %s
39
40# RUN: ld.lld --build-id=md5 --build-id=none %t -o %t2
41# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=NONE %s
42# RUN: ld.lld --build-id --build-id=none %t -o %t2
43# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=NONE %s
44# RUN: ld.lld --build-id=none --build-id %t -o %t2
45# RUN: llvm-objdump -s %t2 | FileCheck --check-prefix=SHA1 %s
46
47.globl _start
48_start:
49  nop
50
51.section .note.test, "a", @note
52   .quad 42
53
54# ALIGN:      Name: .note.gnu.build-id
55# ALIGN-NEXT: Type: SHT_NOTE
56# ALIGN-NEXT: Flags [
57# ALIGN-NEXT:   SHF_ALLOC
58# ALIGN-NEXT: ]
59# ALIGN-NEXT: Address:
60# ALIGN-NEXT: Offset: [[_:0x[0-9A-Z]*(0|4|8|C)$]]
61# ALIGN-NEXT: Size:
62# ALIGN-NEXT: Link:
63# ALIGN-NEXT: Info:
64# ALIGN-NEXT: AddressAlignment: 4
65
66# FAST:      Contents of section .note.test:
67# FAST:      Contents of section .note.gnu.build-id:
68# FAST-NEXT: 04000000 08000000 03000000 474e5500  ............GNU.
69# FAST-NEXT: 630bc2f5 a2584763
70
71# MD5:      Contents of section .note.gnu.build-id:
72# MD5-NEXT: 04000000 10000000 03000000 474e5500  ............GNU.
73# MD5-NEXT: dbf0bc13 b3ff11e9 fde6e17c 0304983c
74
75# SHA1:      Contents of section .note.gnu.build-id:
76# SHA1-NEXT: 04000000 14000000 03000000 474e5500  ............GNU.
77# SHA1-NEXT: 1215775f d3b60050 70afd970 e8a10972
78
79# UUID:      Contents of section .note.gnu.build-id:
80# UUID-NEXT: 04000000 10000000 03000000 474e5500  ............GNU.
81
82# HEX:      Contents of section .note.gnu.build-id:
83# HEX-NEXT: 04000000 04000000 03000000 474e5500  ............GNU.
84# HEX-NEXT: 12345678
85
86# NONE-NOT: Contents of section .note.gnu.build-id:
87
88# RUN: ld.lld --build-id=sha1 -z separate-loadable-segments %t -o %t2
89# RUN: llvm-readelf -x .note.gnu.build-id %t2 | FileCheck --check-prefix=SEPARATE %s
90
91# SEPARATE:      Hex dump of section '.note.gnu.build-id':
92# SEPARATE-NEXT: 0x00200198 04000000 14000000 03000000 474e5500
93# SEPARATE-NEXT: 0x002001a8 5cd067a4 2631c0fd 42029037 4b8e0938
94
95# RUN: ld.lld --build-id=sha1 --no-rosegment %t -o %t2
96# RUN: llvm-readelf -x .note.gnu.build-id %t2 | FileCheck --check-prefix=NORO %s
97
98# NORO:      Hex dump of section '.note.gnu.build-id':
99# NORO-NEXT: 0x00200160 04000000 14000000 03000000 474e5500
100# NORO-NEXT: 0x00200170 a328cc99 45bfc3fc a9fc8615 37102f9d
101