--- /dev/null
+// REQUIRES: x86-registered-target
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t.o
+
+// RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM
+// RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU
+
+// GNU: Displaying notes found
+// GNU-NEXT: Owner Data size Description
+// GNU-NEXT: AMD 0x00000000 NT_AMD_AMDGPU_HSA_METADATA (HSA Metadata)
+// GNU-NEXT: HSA Metadata:
+// GNU-NEXT: {{^ +$}}
+// GNU-EMPTY:
+// GNU-NEXT: AMD 0x00000000 NT_AMD_AMDGPU_ISA (ISA Version)
+// GNU-NEXT: ISA Version:
+// GNU-NEXT: {{^ +$}}
+// GNU-EMPTY:
+// GNU-NEXT: Displaying notes found
+// GNU-NEXT: Owner Data size Description
+// GNU-NEXT: AMD 0x0000000a NT_AMD_AMDGPU_HSA_METADATA (HSA Metadata)
+// GNU-NEXT: HSA Metadata:
+// GNU-NEXT: meta_blah
+// GNU-EMPTY:
+// GNU-NEXT: AMD 0x00000009 NT_AMD_AMDGPU_ISA (ISA Version)
+// GNU-NEXT: ISA Version:
+// GNU-NEXT: isa_blah
+// GNU-EMPTY:
+// GNU-NEXT: Displaying notes found
+// GNU-NEXT: Owner Data size Description
+// GNU-NEXT: AMD 0x00000000 NT_AMD_AMDGPU_PAL_METADATA (PAL Metadata)
+
+// LLVM: Notes [
+// LLVM-NEXT: NoteSection {
+// LLVM-NEXT: Offset:
+// LLVM-NEXT: Size:
+// LLVM-NEXT: Note {
+// LLVM-NEXT: Owner: AMD
+// LLVM-NEXT: Data size: 0x0
+// LLVM-NEXT: Type: NT_AMD_AMDGPU_HSA_METADATA (HSA Metadata)
+// LLVM-NEXT: HSA Metadata:
+// LLVM-NEXT: }
+// LLVM-NEXT: Note {
+// LLVM-NEXT: Owner: AMD
+// LLVM-NEXT: Data size: 0x0
+// LLVM-NEXT: Type: NT_AMD_AMDGPU_ISA (ISA Version)
+// LLVM-NEXT: ISA Version:
+// LLVM-NEXT: }
+// LLVM-NEXT: }
+// LLVM-NEXT: NoteSection {
+// LLVM-NEXT: Offset:
+// LLVM-NEXT: Size:
+// LLVM-NEXT: Note {
+// LLVM-NEXT: Owner: AMD
+// LLVM-NEXT: Data size: 0xA
+// LLVM-NEXT: Type: NT_AMD_AMDGPU_HSA_METADATA (HSA Metadata)
+// LLVM-NEXT: HSA Metadata: meta_blah
+// LLVM-NEXT: }
+// LLVM-NEXT: Note {
+// LLVM-NEXT: Owner: AMD
+// LLVM-NEXT: Data size: 0x9
+// LLVM-NEXT: Type: NT_AMD_AMDGPU_ISA (ISA Version)
+// LLVM-NEXT: ISA Version: isa_blah
+// LLVM-NEXT: }
+// LLVM-NEXT: }
+// LLVM-NEXT: NoteSection {
+// LLVM-NEXT: Offset:
+// LLVM-NEXT: Size:
+// LLVM-NEXT: Note {
+// LLVM-NEXT: Owner: AMD
+// LLVM-NEXT: Data size: 0x0
+// LLVM-NEXT: Type: NT_AMD_AMDGPU_PAL_METADATA (PAL Metadata)
+// LLVM-NEXT: }
+// LLVM-NEXT: }
+// LLVM-NEXT: ]
+
+.section ".note.no.desc", "a"
+ .align 4
+ .long 4 /* namesz */
+ .long 0 /* descsz */
+ .long 10 /* type = NT_AMD_AMDGPU_HSA_METADATA */
+ .asciz "AMD"
+ .long 4 /* namesz */
+ .long 0 /* descsz */
+ .long 11 /* type = NT_AMD_AMDGPU_ISA */
+ .asciz "AMD"
+.section ".note.desc", "a"
+ .align 4
+ .long 4 /* namesz */
+ .long end.meta - begin.meta /* descsz */
+ .long 10 /* type = NT_AMD_AMDGPU_HSA_METADATA */
+ .asciz "AMD"
+begin.meta:
+ .asciz "meta_blah"
+end.meta:
+ .align 4
+ .long 4 /* namesz */
+ .long end.isa - begin.isa /* descsz */
+ .long 11 /* type = NT_AMD_AMDGPU_ISA */
+ .asciz "AMD"
+begin.isa:
+ .asciz "isa_blah"
+end.isa:
+ .align 4
+.section ".note.other", "a"
+ .align 4
+ .long 4 /* namesz */
+ .long 0 /* descsz */
+ .long 12 /* type = NT_AMD_AMDGPU_PAL_METADATA */
+ .asciz "AMD"
--- /dev/null
+# RUN: yaml2obj %s > %t.o
+# RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM
+# RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU
+
+# GNU: Displaying notes found
+# GNU-NEXT: Owner Data size Description
+# GNU-NEXT: AMDGPU 0x000000e6 NT_AMDGPU_METADATA (AMDGPU Metadata)
+# GNU-NEXT: AMDGPU Metadata:
+# GNU-NEXT: ---
+# GNU-NEXT: amdhsa.kernels:
+# GNU-NEXT: - .group_segment_fixed_size: 2
+# GNU-NEXT: .kernarg_segment_align: 4
+# GNU-NEXT: .kernarg_segment_size: 1
+# GNU-NEXT: .max_flat_workgroup_size: 8
+# GNU-NEXT: .name: foo
+# GNU-NEXT: .private_segment_fixed_size: 3
+# GNU-NEXT: .sgpr_count: 6
+# GNU-NEXT: .symbol: foo
+# GNU-NEXT: .vgpr_count: 7
+# GNU-NEXT: .wavefront_size: 5
+# GNU-NEXT: amdhsa.version:
+# GNU-NEXT: - 1
+# GNU-NEXT: - 0
+# GNU-NEXT: ...
+
+# LLVM: Notes [
+# LLVM-NEXT: NoteSection {
+# LLVM-NEXT: Offset:
+# LLVM-NEXT: Size:
+# LLVM-NEXT: Note {
+# LLVM-NEXT: Owner: AMDGPU
+# LLVM-NEXT: Data size: 0xE6
+# LLVM-NEXT: Type: NT_AMDGPU_METADATA (AMDGPU Metadata)
+# LLVM-NEXT: AMDGPU Metadata: ---
+# LLVM-NEXT: amdhsa.kernels:
+# LLVM-NEXT: - .group_segment_fixed_size: 2
+# LLVM-NEXT: .kernarg_segment_align: 4
+# LLVM-NEXT: .kernarg_segment_size: 1
+# LLVM-NEXT: .max_flat_workgroup_size: 8
+# LLVM-NEXT: .name: foo
+# LLVM-NEXT: .private_segment_fixed_size: 3
+# LLVM-NEXT: .sgpr_count: 6
+# LLVM-NEXT: .symbol: foo
+# LLVM-NEXT: .vgpr_count: 7
+# LLVM-NEXT: .wavefront_size: 5
+# LLVM-NEXT: amdhsa.version:
+# LLVM-NEXT: - 1
+# LLVM-NEXT: - 0
+# LLVM-NEXT: ...
+# LLVM-EMPTY:
+# LLVM-NEXT: }
+# LLVM-NEXT: }
+# LLVM-NEXT: ]
+
+## Use yaml2obj instead of llvm-mc for more test portability. This was
+## generated by grabbing section data from an object built via:
+# $ llvm-mc -filetype=obj -triple amdgcn-amd-amdhsa -mattr=+code-object-v3 %s -o %t.o
+## On input:
+# .amdgpu_metadata
+# amdhsa.version:
+# - 1
+# - 0
+# amdhsa.kernels:
+# - .name: foo
+# .symbol: foo
+# .kernarg_segment_size: 1
+# .group_segment_fixed_size: 2
+# .private_segment_fixed_size: 3
+# .kernarg_segment_align: 4
+# .wavefront_size: 5
+# .sgpr_count: 6
+# .vgpr_count: 7
+# .max_flat_workgroup_size: 8
+# .end_amdgpu_metadata
+
+--- !ELF
+FileHeader:
+ Class: ELFCLASS64
+ Data: ELFDATA2LSB
+ Type: ET_REL
+ Machine: EM_X86_64
+Sections:
+ - Name: .note.foo
+ Type: SHT_NOTE
+ Content: 07000000E600000020000000414D44475055000082AE616D646873612E6B65726E656C73918AB92E67726F75705F7365676D656E745F66697865645F73697A6502B62E6B65726E6172675F7365676D656E745F616C69676E04B52E6B65726E6172675F7365676D656E745F73697A6501B82E6D61785F666C61745F776F726B67726F75705F73697A6508A52E6E616D65A3666F6FBB2E707269766174655F7365676D656E745F66697865645F73697A6503AB2E736770725F636F756E7406A72E73796D626F6CA3666F6FAB2E766770725F636F756E7407AF2E7761766566726F6E745F73697A6505AE616D646873612E76657273696F6E9201000000
--- /dev/null
+// REQUIRES: x86-registered-target
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t.o
+
+// RUN: llvm-readobj --notes %t.o | FileCheck %s --check-prefix=LLVM
+// RUN: llvm-readelf --notes %t.o | FileCheck %s --check-prefix=GNU
+
+// GNU: Displaying notes found
+// GNU-NEXT: Owner Data size Description
+// GNU-NEXT: FreeBSD 0x00000000 NT_THRMISC (thrmisc structure)
+// GNU-EMPTY:
+// GNU-NEXT: FreeBSD 0x00000000 NT_PROCSTAT_PROC (proc data)
+// GNU-EMPTY:
+// GNU-NEXT: Displaying notes found
+// GNU-NEXT: Owner Data size Description
+// GNU-NEXT: FreeBSD 0x00000000 NT_PROCSTAT_FILES (files data)
+
+// LLVM: Notes [
+// LLVM-NEXT: NoteSection {
+// LLVM-NEXT: Offset:
+// LLVM-NEXT: Size:
+// LLVM-NEXT: Note {
+// LLVM-NEXT: Owner: FreeBSD
+// LLVM-NEXT: Data size: 0x0
+// LLVM-NEXT: Type: NT_THRMISC (thrmisc structure)
+// LLVM-NEXT: }
+// LLVM-NEXT: Note {
+// LLVM-NEXT: Owner: FreeBSD
+// LLVM-NEXT: Data size: 0x0
+// LLVM-NEXT: Type: NT_PROCSTAT_PROC (proc data)
+// LLVM-NEXT: }
+// LLVM-NEXT: }
+// LLVM-NEXT: NoteSection {
+// LLVM-NEXT: Offset: 0x68
+// LLVM-NEXT: Size: 0x14
+// LLVM-NEXT: Note {
+// LLVM-NEXT: Owner: FreeBSD
+// LLVM-NEXT: Data size: 0x0
+// LLVM-NEXT: Type: NT_PROCSTAT_FILES (files data)
+// LLVM-NEXT: }
+// LLVM-NEXT: }
+// LLVM-NEXT: ]
+
+.section ".note.foo", "a"
+ .align 4
+ .long 8 /* namesz */
+ .long 0 /* descsz */
+ .long 7 /* type = NT_FREEBSD_THRMISC */
+ .asciz "FreeBSD"
+ .long 8 /* namesz */
+ .long 0 /* descsz */
+ .long 8 /* type = NT_FREEBSD_PROC */
+ .asciz "FreeBSD"
+.section ".note.bar", "a"
+ .align 4
+ .long 8 /* namesz */
+ .long 0 /* descsz */
+ .long 9 /* type = NT_FREEBSD_FILES */
+ .asciz "FreeBSD"