1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

Fixing r116753 r116756 r116777

The failures in r116753 r116756 were caused by a python issue -
Python likes to append 'L' suffix to stringified numbers if the number
is larger than a machine int. Unfortunately, this causes a divergence of
behavior between 32 and 64 bit python versions.

I re-crafted elf-dump/common_dump to take care of these issues by:

1. always printing 0x (makes for easy sed/regex)
2. always print fixed length (exactly 2 + numBits/4 digits long)
   by mod ((2^numBits) - 1)
3. left-padded with '0'

There is a residual common routine that is also used by
macho-dump (dataToHex) , so I left the 'section_data' test values alone.

llvm-svn: 116823
This commit is contained in:
Jason W Kim 2010-10-19 17:39:10 +00:00
parent 46990c17f7
commit ccbc75257a
33 changed files with 617 additions and 582 deletions

View File

@ -15,70 +15,70 @@ bar3 = foo3
foo4:
bar4 = foo4
// CHECK: # Symbol 1
// CHECK-NEXT: (('st_name', 5) # 'bar'
// CHECK-NEXT: ('st_bind', 0)
// CHECK-NEXT: ('st_type', 0)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 1)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK: # Symbol 0x00000001
// CHECK-NEXT: (('st_name', 0x00000005) # 'bar'
// CHECK-NEXT: ('st_bind', 0x00000000)
// CHECK-NEXT: ('st_type', 0x00000000)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x00000001)
// CHECK-NEXT: ('st_value', 0x00000000)
// CHECK-NEXT: ('st_size', 0x00000000)
// CHECK-NEXT: ),
// CHECK-NEXT: # Symbol 2
// CHECK-NEXT: (('st_name', 29) # 'bar4'
// CHECK-NEXT: ('st_bind', 0)
// CHECK-NEXT: ('st_type', 2)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 1)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK-NEXT: # Symbol 0x00000002
// CHECK-NEXT: (('st_name', 0x0000001d) # 'bar4'
// CHECK-NEXT: ('st_bind', 0x00000000)
// CHECK-NEXT: ('st_type', 0x00000002)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x00000001)
// CHECK-NEXT: ('st_value', 0x00000000)
// CHECK-NEXT: ('st_size', 0x00000000)
// CHECK-NEXT: ),
// CHECK-NEXT: # Symbol 3
// CHECK-NEXT: (('st_name', 1) # 'foo'
// CHECK-NEXT: ('st_bind', 0)
// CHECK-NEXT: ('st_type', 0)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 1)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK-NEXT: # Symbol 0x00000003
// CHECK-NEXT: (('st_name', 0x00000001) # 'foo'
// CHECK-NEXT: ('st_bind', 0x00000000)
// CHECK-NEXT: ('st_type', 0x00000000)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x00000001)
// CHECK-NEXT: ('st_value', 0x00000000)
// CHECK-NEXT: ('st_size', 0x00000000)
// CHECK-NEXT: ),
// CHECK-NEXT: # Symbol 4
// CHECK-NEXT: (('st_name', 14) # 'foo3'
// CHECK-NEXT: ('st_bind', 0)
// CHECK-NEXT: ('st_type', 0)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 1)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK-NEXT: # Symbol 0x00000004
// CHECK-NEXT: (('st_name', 0x0000000e) # 'foo3'
// CHECK-NEXT: ('st_bind', 0x00000000)
// CHECK-NEXT: ('st_type', 0x00000000)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x00000001)
// CHECK-NEXT: ('st_value', 0x00000000)
// CHECK-NEXT: ('st_size', 0x00000000)
// CHECK-NEXT: ),
// CHECK-NEXT: # Symbol 5
// CHECK-NEXT: (('st_name', 24) # 'foo4'
// CHECK-NEXT: ('st_bind', 0)
// CHECK-NEXT: ('st_type', 2)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 1)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK-NEXT: # Symbol 0x00000005
// CHECK-NEXT: (('st_name', 0x00000018) # 'foo4'
// CHECK-NEXT: ('st_bind', 0x00000000)
// CHECK-NEXT: ('st_type', 0x00000002)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x00000001)
// CHECK-NEXT: ('st_value', 0x00000000)
// CHECK-NEXT: ('st_size', 0x00000000)
// CHECK-NEXT: ),
// CHECK-NEXT: # Symbol 6
// CHECK-NEXT: (('st_name', 0) # ''
// CHECK: # Symbol 7
// CHECK-NEXT: (('st_name', 0) # ''
// CHECK: # Symbol 8
// CHECK-NEXT: (('st_name', 0) # ''
// CHECK: # Symbol 9
// CHECK-NEXT: (('st_name', 19) # 'bar3'
// CHECK-NEXT: ('st_bind', 1)
// CHECK-NEXT: ('st_type', 0)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 1)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK: # Symbol 10
// CHECK-NEXT: (('st_name', 9) # 'bar2'
// CHECK-NEXT: ('st_bind', 1)
// CHECK-NEXT: ('st_type', 0)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 0)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK-NEXT: # Symbol 0x00000006
// CHECK-NEXT: (('st_name', 0x00000000) # ''
// CHECK: # Symbol 0x00000007
// CHECK-NEXT: (('st_name', 0x00000000) # ''
// CHECK: # Symbol 0x00000008
// CHECK-NEXT: (('st_name', 0x00000000) # ''
// CHECK: # Symbol 0x00000009
// CHECK-NEXT: (('st_name', 0x00000013) # 'bar3'
// CHECK-NEXT: ('st_bind', 0x00000001)
// CHECK-NEXT: ('st_type', 0x00000000)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x00000001)
// CHECK-NEXT: ('st_value', 0x00000000)
// CHECK-NEXT: ('st_size', 0x00000000)
// CHECK: # Symbol 0x0000000a
// CHECK-NEXT: (('st_name', 0x00000009) # 'bar2'
// CHECK-NEXT: ('st_bind', 0x00000001)
// CHECK-NEXT: ('st_type', 0x00000000)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x00000000)
// CHECK-NEXT: ('st_value', 0x00000000)
// CHECK-NEXT: ('st_size', 0x00000000)

View File

@ -5,13 +5,13 @@
.local foo
.comm foo,2048,16
// CHECK: ('sh_name', 13) # '.bss'
// CHECK-NEXT: ('sh_type', 8)
// CHECK-NEXT: ('sh_flags', 3)
// CHECK-NEXT: ('sh_addr', 0)
// CHECK-NEXT: ('sh_offset', 64)
// CHECK-NEXT: ('sh_size', 2048)
// CHECK-NEXT: ('sh_link', 0)
// CHECK-NEXT: ('sh_info', 0)
// CHECK-NEXT: ('sh_addralign', 16)
// CHECK-NEXT: ('sh_entsize', 0)
// CHECK: ('sh_name', 0x0000000d) # '.bss'
// CHECK-NEXT: ('sh_type', 0x00000008)
// CHECK-NEXT: ('sh_flags', 0x00000003)
// CHECK-NEXT: ('sh_addr', 0x00000000)
// CHECK-NEXT: ('sh_offset', 0x00000040)
// CHECK-NEXT: ('sh_size', 0x00000800)
// CHECK-NEXT: ('sh_link', 0x00000000)
// CHECK-NEXT: ('sh_info', 0x00000000)
// CHECK-NEXT: ('sh_addralign', 0x00000010)
// CHECK-NEXT: ('sh_entsize', 0x00000000)

View File

@ -4,37 +4,37 @@
.text
f0:
.long 0
.align 8, 0x90
.align 8, 0x00000090
.long 0
.align 8
// But not in another section
.data
.long 0
.align 8, 0x90
.align 8, 0x00000090
.long 0
.align 8
// CHECK: (('sh_name', 1) # '.text'
// CHECK-NEXT: ('sh_type', 1)
// CHECK-NEXT: ('sh_flags', 6)
// CHECK: (('sh_name', 0x00000001) # '.text'
// CHECK-NEXT: ('sh_type', 0x00000001)
// CHECK-NEXT: ('sh_flags', 0x00000006)
// CHECK-NEXT: ('sh_addr',
// CHECK-NEXT: ('sh_offset',
// CHECK-NEXT: ('sh_size', 16)
// CHECK-NEXT: ('sh_link', 0)
// CHECK-NEXT: ('sh_info', 0)
// CHECK-NEXT: ('sh_addralign', 8)
// CHECK-NEXT: ('sh_entsize', 0)
// CHECK-NEXT: ('sh_size', 0x00000010)
// CHECK-NEXT: ('sh_link', 0x00000000)
// CHECK-NEXT: ('sh_info', 0x00000000)
// CHECK-NEXT: ('sh_addralign', 0x00000008)
// CHECK-NEXT: ('sh_entsize', 0x00000000)
// CHECK-NEXT: ('_section_data', '00000000 0f1f4000 00000000 0f1f4000')
// CHECK: (('sh_name', 7) # '.data'
// CHECK-NEXT: ('sh_type', 1)
// CHECK-NEXT: ('sh_flags', 3)
// CHECK: (('sh_name', 0x00000007) # '.data'
// CHECK-NEXT: ('sh_type', 0x00000001)
// CHECK-NEXT: ('sh_flags', 0x00000003)
// CHECK-NEXT: ('sh_addr',
// CHECK-NEXT: ('sh_offset',
// CHECK-NEXT: ('sh_size', 16)
// CHECK-NEXT: ('sh_link', 0)
// CHECK-NEXT: ('sh_info', 0)
// CHECK-NEXT: ('sh_addralign', 8)
// CHECK-NEXT: ('sh_entsize', 0)
// CHECK-NEXT: ('sh_size', 0x00000010)
// CHECK-NEXT: ('sh_link', 0x00000000)
// CHECK-NEXT: ('sh_info', 0x00000000)
// CHECK-NEXT: ('sh_addralign', 0x00000008)
// CHECK-NEXT: ('sh_entsize', 0x00000000)
// CHECK-NEXT: ('_section_data', '00000000 90909090 00000000 00000000')

View File

@ -5,9 +5,9 @@
.zero 4
.align 8
// CHECK: (('sh_name', 1) # '.text'
// CHECK-NEXT: ('sh_type', 1)
// CHECK-NEXT: ('sh_flags', 6)
// CHECK-NEXT: ('sh_addr', 0)
// CHECK-NEXT: ('sh_offset', 64)
// CHECK-NEXT: ('sh_size', 8)
// CHECK: (('sh_name', 0x00000001) # '.text'
// CHECK-NEXT: ('sh_type', 0x00000001)
// CHECK-NEXT: ('sh_flags', 0x00000006)
// CHECK-NEXT: ('sh_addr', 0x00000000)
// CHECK-NEXT: ('sh_offset', 0x00000040)
// CHECK-NEXT: ('sh_size', 0x00000008)

View File

@ -6,14 +6,14 @@
.text
.zero 1
// CHECK: (('sh_name', 1) # '.text'
// CHECK-NEXT: ('sh_type', 1)
// CHECK-NEXT: ('sh_flags', 6)
// CHECK-NEXT: ('sh_addr', 0)
// CHECK-NEXT: ('sh_offset', 64)
// CHECK-NEXT: ('sh_size', 2)
// CHECK-NEXT: ('sh_link', 0)
// CHECK-NEXT: ('sh_info', 0)
// CHECK-NEXT: ('sh_addralign', 4)
// CHECK-NEXT: ('sh_entsize', 0)
// CHECK: (('sh_name', 0x00000001) # '.text'
// CHECK-NEXT: ('sh_type', 0x00000001)
// CHECK-NEXT: ('sh_flags', 0x00000006)
// CHECK-NEXT: ('sh_addr', 0x00000000)
// CHECK-NEXT: ('sh_offset', 0x00000040)
// CHECK-NEXT: ('sh_size', 0x00000002)
// CHECK-NEXT: ('sh_link', 0x00000000)
// CHECK-NEXT: ('sh_info', 0x00000000)
// CHECK-NEXT: ('sh_addralign', 0x00000004)
// CHECK-NEXT: ('sh_entsize', 0x00000000)
// CHECK-NEXT: ),

View File

@ -7,26 +7,26 @@
.section .rodata,"a",@progbits
.align 8
// CHECK: # Section 3
// CHECK-NEXT: (('sh_name', 13) # '.bss'
// CHECK-NEXT: ('sh_type', 8)
// CHECK-NEXT: ('sh_flags', 3)
// CHECK-NEXT: ('sh_addr', 0)
// CHECK-NEXT: ('sh_offset', 68)
// CHECK-NEXT: ('sh_size', 0)
// CHECK-NEXT: ('sh_link', 0)
// CHECK-NEXT: ('sh_info', 0)
// CHECK-NEXT: ('sh_addralign', 4)
// CHECK-NEXT: ('sh_entsize', 0)
// CHECK: # Section 0x00000003
// CHECK-NEXT: (('sh_name', 0x0000000d) # '.bss'
// CHECK-NEXT: ('sh_type', 0x00000008)
// CHECK-NEXT: ('sh_flags', 0x00000003)
// CHECK-NEXT: ('sh_addr', 0x00000000)
// CHECK-NEXT: ('sh_offset', 0x00000044)
// CHECK-NEXT: ('sh_size', 0x00000000)
// CHECK-NEXT: ('sh_link', 0x00000000)
// CHECK-NEXT: ('sh_info', 0x00000000)
// CHECK-NEXT: ('sh_addralign', 0x00000004)
// CHECK-NEXT: ('sh_entsize', 0x00000000)
// CHECK-NEXT: ),
// CHECK-NEXT: # Section 4
// CHECK-NEXT: (('sh_name', 18) # '.rodata'
// CHECK-NEXT: ('sh_type', 1)
// CHECK-NEXT: ('sh_flags', 2)
// CHECK-NEXT: ('sh_addr', 0)
// CHECK-NEXT: ('sh_offset', 72)
// CHECK-NEXT: ('sh_size', 0)
// CHECK-NEXT: ('sh_link', 0)
// CHECK-NEXT: ('sh_info', 0)
// CHECK-NEXT: ('sh_addralign', 8)
// CHECK-NEXT: ('sh_entsize', 0)
// CHECK-NEXT: # Section 0x00000004
// CHECK-NEXT: (('sh_name', 0x00000012) # '.rodata'
// CHECK-NEXT: ('sh_type', 0x00000001)
// CHECK-NEXT: ('sh_flags', 0x00000002)
// CHECK-NEXT: ('sh_addr', 0x00000000)
// CHECK-NEXT: ('sh_offset', 0x00000048)
// CHECK-NEXT: ('sh_size', 0x00000000)
// CHECK-NEXT: ('sh_link', 0x00000000)
// CHECK-NEXT: ('sh_info', 0x00000000)
// CHECK-NEXT: ('sh_addralign', 0x00000008)
// CHECK-NEXT: ('sh_entsize', 0x00000000)

View File

@ -12,100 +12,100 @@ define i32 @main() nounwind {
declare i32 @puts(i8* nocapture) nounwind
; 32: ('e_indent[EI_CLASS]', 1)
; 32: ('e_indent[EI_DATA]', 1)
; 32: ('e_indent[EI_VERSION]', 1)
; 32: ('e_indent[EI_CLASS]', 0x00000001)
; 32: ('e_indent[EI_DATA]', 0x00000001)
; 32: ('e_indent[EI_VERSION]', 0x00000001)
; 32: ('_sections', [
; 32: # Section 0
; 32: (('sh_name', 0) # ''
; 32: (('sh_name', 0x00000000) # ''
; 32: # '.text'
; 32: ('st_bind', 0)
; 32: ('st_type', 3)
; 32: ('st_bind', 0x00000000)
; 32: ('st_type', 0x00000003)
; 32: ('st_bind', 0)
; 32: ('st_type', 3)
; 32: ('st_bind', 0x00000000)
; 32: ('st_type', 0x00000003)
; 32: ('st_bind', 0)
; 32: ('st_type', 3)
; 32: ('st_bind', 0x00000000)
; 32: ('st_type', 0x00000003)
; 32: # 'main'
; 32: ('st_bind', 1)
; 32-NEXT: ('st_type', 2)
; 32: ('st_bind', 0x00000001)
; 32-NEXT: ('st_type', 0x00000002)
; 32: # 'puts'
; 32: ('st_bind', 1)
; 32-NEXT: ('st_type', 0)
; 32: ('st_bind', 0x00000001)
; 32-NEXT: ('st_type', 0x00000000)
; 32: # '.rel.text'
; 32: ('_relocations', [
; 32: # Relocation 0
; 32: (('r_offset', 6)
; 32: ('r_type', 1)
; 32: # Relocation 0x00000000
; 32: (('r_offset', 0x00000006)
; 32: ('r_type', 0x00000001)
; 32: ),
; 32: # Relocation 1
; 32: (('r_offset', 11)
; 32: ('r_type', 2)
; 32: # Relocation 0x00000001
; 32: (('r_offset', 0x0000000b)
; 32: ('r_type', 0x00000002)
; 32: ),
; 32: # Relocation 2
; 32: (('r_offset', 18)
; 32: ('r_type', 1)
; 32: # Relocation 0x00000002
; 32: (('r_offset', 0x00000012)
; 32: ('r_type', 0x00000001)
; 32: ),
; 32: # Relocation 3
; 32: (('r_offset', 23)
; 32: ('r_type', 2)
; 32: # Relocation 0x00000003
; 32: (('r_offset', 0x00000017)
; 32: ('r_type', 0x00000002)
; 32: ),
; 32: ])
; 64: ('e_indent[EI_CLASS]', 2)
; 64: ('e_indent[EI_DATA]', 1)
; 64: ('e_indent[EI_VERSION]', 1)
; 64: ('e_indent[EI_CLASS]', 0x00000002)
; 64: ('e_indent[EI_DATA]', 0x00000001)
; 64: ('e_indent[EI_VERSION]', 0x00000001)
; 64: ('_sections', [
; 64: # Section 0
; 64: (('sh_name', 0) # ''
; 64: (('sh_name', 0x00000000) # ''
; 64: # '.text'
; 64: ('st_bind', 0)
; 64: ('st_type', 3)
; 64: ('st_bind', 0x00000000)
; 64: ('st_type', 0x00000003)
; 64: ('st_bind', 0)
; 64: ('st_type', 3)
; 64: ('st_bind', 0x00000000)
; 64: ('st_type', 0x00000003)
; 64: ('st_bind', 0)
; 64: ('st_type', 3)
; 64: ('st_bind', 0x00000000)
; 64: ('st_type', 0x00000003)
; 64: # 'main'
; 64-NEXT: ('st_bind', 1)
; 64-NEXT: ('st_type', 2)
; 64-NEXT: ('st_bind', 0x00000001)
; 64-NEXT: ('st_type', 0x00000002)
; 64: # 'puts'
; 64-NEXT: ('st_bind', 1)
; 64-NEXT: ('st_type', 0)
; 64-NEXT: ('st_bind', 0x00000001)
; 64-NEXT: ('st_type', 0x00000000)
; 64: # '.rela.text'
; 64: ('_relocations', [
; 64: # Relocation 0
; 64: (('r_offset', 5)
; 64: ('r_type', 10)
; 64: ('r_addend', 0)
; 64: # Relocation 0x00000000
; 64: (('r_offset', 0x00000005)
; 64: ('r_type', 0x0000000a)
; 64: ('r_addend', 0x00000000)
; 64: ),
; 64: # Relocation 1
; 64: (('r_offset', 10)
; 64: ('r_type', 2)
; 64: ('r_addend', -4)
; 64: # Relocation 0x00000001
; 64: (('r_offset', 0x0000000a)
; 64: ('r_type', 0x00000002)
; 64: ('r_addend', 0xfffffffc)
; 64: ),
; 64: # Relocation 2
; 64: (('r_offset', 15)
; 64: ('r_type', 10)
; 64: ('r_addend', 6)
; 64: # Relocation 0x00000002
; 64: (('r_offset', 0x0000000f)
; 64: ('r_type', 0x0000000a)
; 64: ('r_addend', 0x00000006)
; 64: ),
; 64: # Relocation 3
; 64: (('r_offset', 20)
; 64: ('r_type', 2)
; 64: ('r_addend', -4)
; 64: # Relocation 0x00000003
; 64: (('r_offset', 0x00000014)
; 64: ('r_type', 0x00000002)
; 64: ('r_addend', 0xfffffffc)
; 64: ),
; 64: ])

View File

@ -8,13 +8,13 @@
.local common1
.comm common1,1,1
// CHECK: ('st_name', 1) # 'common1'
// CHECK-NEXT: ('st_bind', 0)
// CHECK-NEXT: ('st_type', 1)
// CHECK-NEXT: ('st_other', 0)
// CHECK: ('st_name', 0x00000001) # 'common1'
// CHECK-NEXT: ('st_bind', 0x00000000)
// CHECK-NEXT: ('st_type', 0x00000001)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx',
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 1)
// CHECK-NEXT: ('st_value', 0x00000000)
// CHECK-NEXT: ('st_size', 0x00000001)
// Same as common1, but with directives in a different order.
@ -22,25 +22,25 @@
.type common2,@object
.comm common2,1,1
// CHECK: ('st_name', 9) # 'common2'
// CHECK-NEXT: ('st_bind', 0)
// CHECK-NEXT: ('st_type', 1)
// CHECK-NEXT: ('st_other', 0)
// CHECK: ('st_name', 0x00000009) # 'common2'
// CHECK-NEXT: ('st_bind', 0x00000000)
// CHECK-NEXT: ('st_type', 0x00000001)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx',
// CHECK-NEXT: ('st_value', 1)
// CHECK-NEXT: ('st_size', 1)
// CHECK-NEXT: ('st_value', 0x00000001)
// CHECK-NEXT: ('st_size', 0x00000001)
// Test that without an explicit .local we produce a global.
.type common3,@object
.comm common3,4,4
// CHECK: ('st_name', 17) # 'common3'
// CHECK-NEXT: ('st_bind', 1)
// CHECK-NEXT: ('st_type', 1)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 65522)
// CHECK-NEXT: ('st_value', 4)
// CHECK-NEXT: ('st_size', 4)
// CHECK: ('st_name', 0x00000011) # 'common3'
// CHECK-NEXT: ('st_bind', 0x00000001)
// CHECK-NEXT: ('st_type', 0x00000001)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x0000fff2)
// CHECK-NEXT: ('st_value', 0x00000004)
// CHECK-NEXT: ('st_size', 0x00000004)
// Test that without an explicit .local we produce a global, even if the first
@ -54,10 +54,10 @@ foo:
.type common4,@object
.comm common4,40,16
// CHECK: ('st_name', 29) # 'common4'
// CHECK-NEXT: ('st_bind', 1)
// CHECK-NEXT: ('st_type', 1)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 65522)
// CHECK-NEXT: ('st_value', 16)
// CHECK-NEXT: ('st_size', 40)
// CHECK: ('st_name', 0x0000001d) # 'common4'
// CHECK-NEXT: ('st_bind', 0x00000001)
// CHECK-NEXT: ('st_type', 0x00000001)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x0000fff2)
// CHECK-NEXT: ('st_value', 0x00000010)
// CHECK-NEXT: ('st_size', 0x00000028)

View File

@ -9,12 +9,12 @@
.zero 1
.align 8
// CHECK: (('sh_name', 13) # '.bss'
// CHECK: (('sh_name', 0x0000000d) # '.bss'
// CHECK-NEXT: ('sh_type',
// CHECK-NEXT: ('sh_flags'
// CHECK-NEXT: ('sh_addr',
// CHECK-NEXT: ('sh_offset',
// CHECK-NEXT: ('sh_size', 9)
// CHECK-NEXT: ('sh_size', 0x00000009)
// CHECK-NEXT: ('sh_link',
// CHECK-NEXT: ('sh_info',
// CHECK-NEXT: ('sh_addralign',

View File

@ -8,8 +8,8 @@ bar:
zed:
mov zed+(bar-foo), %eax
// CHECK: # Relocation 0
// CHECK-NEXT: (('r_offset', 5)
// CHECK-NEXT: ('r_sym', 6)
// CHECK-NEXT: ('r_type', 11)
// CHECK-NEXT: ('r_addend', 1)
// CHECK: # Relocation 0x00000000
// CHECK-NEXT: (('r_offset', 0x00000005)
// CHECK-NEXT: ('r_sym', 0x00000006)
// CHECK-NEXT: ('r_type', 0x0000000b)
// CHECK-NEXT: ('r_addend', 0x00000001)

View File

@ -3,68 +3,68 @@
// Test that like gnu as we create text, data and bss by default. Also test
// that shstrtab, symtab and strtab are listed in that order.
// CHECK: ('sh_name', 1) # '.text'
// CHECK-NEXT: ('sh_type', 1)
// CHECK-NEXT: ('sh_flags', 6)
// CHECK-NEXT: ('sh_addr', 0)
// CHECK-NEXT: ('sh_offset', 64)
// CHECK-NEXT: ('sh_size', 0)
// CHECK-NEXT: ('sh_link', 0)
// CHECK-NEXT: ('sh_info', 0)
// CHECK-NEXT: ('sh_addralign', 4)
// CHECK-NEXT: ('sh_entsize', 0)
// CHECK: ('sh_name', 0x00000001) # '.text'
// CHECK-NEXT: ('sh_type', 0x00000001)
// CHECK-NEXT: ('sh_flags', 0x00000006)
// CHECK-NEXT: ('sh_addr', 0x00000000)
// CHECK-NEXT: ('sh_offset', 0x00000040)
// CHECK-NEXT: ('sh_size', 0x00000000)
// CHECK-NEXT: ('sh_link', 0x00000000)
// CHECK-NEXT: ('sh_info', 0x00000000)
// CHECK-NEXT: ('sh_addralign', 0x00000004)
// CHECK-NEXT: ('sh_entsize', 0x00000000)
// CHECK: ('sh_name', 7) # '.data'
// CHECK-NEXT: ('sh_type', 1)
// CHECK-NEXT: ('sh_flags', 3)
// CHECK-NEXT: ('sh_addr', 0)
// CHECK-NEXT: ('sh_offset', 64)
// CHECK-NEXT: ('sh_size', 0)
// CHECK-NEXT: ('sh_link', 0)
// CHECK-NEXT: ('sh_info', 0)
// CHECK-NEXT: ('sh_addralign', 4)
// CHECK-NEXT: ('sh_entsize', 0)
// CHECK: ('sh_name', 0x00000007) # '.data'
// CHECK-NEXT: ('sh_type', 0x00000001)
// CHECK-NEXT: ('sh_flags', 0x00000003)
// CHECK-NEXT: ('sh_addr', 0x00000000)
// CHECK-NEXT: ('sh_offset', 0x00000040)
// CHECK-NEXT: ('sh_size', 0x00000000)
// CHECK-NEXT: ('sh_link', 0x00000000)
// CHECK-NEXT: ('sh_info', 0x00000000)
// CHECK-NEXT: ('sh_addralign', 0x00000004)
// CHECK-NEXT: ('sh_entsize', 0x00000000)
// CHECK: ('sh_name', 13) # '.bss'
// CHECK-NEXT: ('sh_type', 8)
// CHECK-NEXT: ('sh_flags', 3)
// CHECK-NEXT: ('sh_addr', 0)
// CHECK-NEXT: ('sh_offset', 64)
// CHECK-NEXT: ('sh_size', 0)
// CHECK-NEXT: ('sh_link', 0)
// CHECK-NEXT: ('sh_info', 0)
// CHECK-NEXT: ('sh_addralign', 4)
// CHECK-NEXT: ('sh_entsize', 0)
// CHECK: ('sh_name', 0x0000000d) # '.bss'
// CHECK-NEXT: ('sh_type', 0x00000008)
// CHECK-NEXT: ('sh_flags', 0x00000003)
// CHECK-NEXT: ('sh_addr', 0x00000000)
// CHECK-NEXT: ('sh_offset', 0x00000040)
// CHECK-NEXT: ('sh_size', 0x00000000)
// CHECK-NEXT: ('sh_link', 0x00000000)
// CHECK-NEXT: ('sh_info', 0x00000000)
// CHECK-NEXT: ('sh_addralign', 0x00000004)
// CHECK-NEXT: ('sh_entsize', 0x00000000)
// CHECK: ('sh_name', 18) # '.shstrtab'
// CHECK-NEXT: ('sh_type', 3)
// CHECK-NEXT: ('sh_flags', 0)
// CHECK-NEXT: ('sh_addr', 0)
// CHECK-NEXT: ('sh_offset', 64)
// CHECK-NEXT: ('sh_size', 44)
// CHECK-NEXT: ('sh_link', 0)
// CHECK-NEXT: ('sh_info', 0)
// CHECK-NEXT: ('sh_addralign', 1)
// CHECK-NEXT: ('sh_entsize', 0)
// CHECK: ('sh_name', 0x00000012) # '.shstrtab'
// CHECK-NEXT: ('sh_type', 0x00000003)
// CHECK-NEXT: ('sh_flags', 0x00000000)
// CHECK-NEXT: ('sh_addr', 0x00000000)
// CHECK-NEXT: ('sh_offset', 0x00000040)
// CHECK-NEXT: ('sh_size', 0x0000002c)
// CHECK-NEXT: ('sh_link', 0x00000000)
// CHECK-NEXT: ('sh_info', 0x00000000)
// CHECK-NEXT: ('sh_addralign', 0x00000001)
// CHECK-NEXT: ('sh_entsize', 0x00000000)
// CHECK: ('sh_name', 28) # '.symtab'
// CHECK-NEXT: ('sh_type', 2)
// CHECK-NEXT: ('sh_flags', 0)
// CHECK-NEXT: ('sh_addr', 0)
// CHECK: ('sh_name', 0x0000001c) # '.symtab'
// CHECK-NEXT: ('sh_type', 0x00000002)
// CHECK-NEXT: ('sh_flags', 0x00000000)
// CHECK-NEXT: ('sh_addr', 0x00000000)
// CHECK-NEXT: ('sh_offset',
// CHECK-NEXT: ('sh_size', 96)
// CHECK-NEXT: ('sh_link', 6)
// CHECK-NEXT: ('sh_info', 4)
// CHECK-NEXT: ('sh_addralign', 8)
// CHECK-NEXT: ('sh_entsize', 24)
// CHECK-NEXT: ('sh_size', 0x00000060)
// CHECK-NEXT: ('sh_link', 0x00000006)
// CHECK-NEXT: ('sh_info', 0x00000004)
// CHECK-NEXT: ('sh_addralign', 0x00000008)
// CHECK-NEXT: ('sh_entsize', 0x00000018)
// CHECK: ('sh_name', 36) # '.strtab'
// CHECK-NEXT: ('sh_type', 3)
// CHECK-NEXT: ('sh_flags', 0)
// CHECK-NEXT: ('sh_addr', 0)
// CHECK: ('sh_name', 0x00000024) # '.strtab'
// CHECK-NEXT: ('sh_type', 0x00000003)
// CHECK-NEXT: ('sh_flags', 0x00000000)
// CHECK-NEXT: ('sh_addr', 0x00000000)
// CHECK-NEXT: ('sh_offset',
// CHECK-NEXT: ('sh_size', 1)
// CHECK-NEXT: ('sh_link', 0)
// CHECK-NEXT: ('sh_info', 0)
// CHECK-NEXT: ('sh_addralign', 1)
// CHECK-NEXT: ('sh_entsize', 0)
// CHECK-NEXT: ('sh_size', 0x00000001)
// CHECK-NEXT: ('sh_link', 0x00000000)
// CHECK-NEXT: ('sh_info', 0x00000000)
// CHECK-NEXT: ('sh_addralign', 0x00000001)
// CHECK-NEXT: ('sh_entsize', 0x00000000)

View File

@ -20,25 +20,25 @@ declare void @foo(i64* nocapture) nounwind
;;;;;
; 64: (('sh_name', 18) # '.rodata.str1.1'
; 64-NEXT: ('sh_type', 1)
; 64-NEXT: ('sh_flags', 50)
; 64: (('sh_name', 0x00000012) # '.rodata.str1.1'
; 64-NEXT: ('sh_type', 0x00000001)
; 64-NEXT: ('sh_flags', 0x00000032)
; 64-NEXT: ('sh_addr',
; 64-NEXT: ('sh_offset',
; 64-NEXT: ('sh_size', 13)
; 64-NEXT: ('sh_size', 0x0000000d)
; 64-NEXT: ('sh_link',
; 64-NEXT: ('sh_info',
; 64-NEXT: ('sh_addralign', 1)
; 64-NEXT: ('sh_entsize', 1)
; 64-NEXT: ('sh_addralign', 0x00000001)
; 64-NEXT: ('sh_entsize', 0x00000001)
; 64: (('sh_name', 33) # '.rodata.cst8'
; 64-NEXT: ('sh_type', 1)
; 64-NEXT: ('sh_flags', 18)
; 64: (('sh_name', 0x00000021) # '.rodata.cst8'
; 64-NEXT: ('sh_type', 0x00000001)
; 64-NEXT: ('sh_flags', 0x00000012)
; 64-NEXT: ('sh_addr',
; 64-NEXT: ('sh_offset',
; 64-NEXT: ('sh_size', 16)
; 64-NEXT: ('sh_size', 0x00000010)
; 64-NEXT: ('sh_link',
; 64-NEXT: ('sh_info',
; 64-NEXT: ('sh_addralign', 8)
; 64-NEXT: ('sh_entsize', 8)
; 64-NEXT: ('sh_addralign', 0x00000008)
; 64-NEXT: ('sh_entsize', 0x00000008)

View File

@ -32,38 +32,38 @@
.quad 42
.quad 42
// CHECK: # Section 4
// CHECK-NEXT: ('sh_name', 18) # '.rodata.str1.1'
// CHECK-NEXT: ('sh_type', 1)
// CHECK-NEXT: ('sh_flags', 50)
// CHECK: # Section 0x00000004
// CHECK-NEXT: ('sh_name', 0x00000012) # '.rodata.str1.1'
// CHECK-NEXT: ('sh_type', 0x00000001)
// CHECK-NEXT: ('sh_flags', 0x00000032)
// CHECK-NEXT: ('sh_addr',
// CHECK-NEXT: ('sh_offset',
// CHECK-NEXT: ('sh_size', 13)
// CHECK-NEXT: ('sh_size', 0x0000000d)
// CHECK-NEXT: ('sh_link',
// CHECK-NEXT: ('sh_info',
// CHECK-NEXT: ('sh_addralign', 1)
// CHECK-NEXT: ('sh_entsize', 1)
// CHECK-NEXT: ('sh_addralign', 0x00000001)
// CHECK-NEXT: ('sh_entsize', 0x00000001)
// CHECK: # Section 5
// CHECK-NEXT: ('sh_name', 33) # '.rodata.str2.1'
// CHECK-NEXT: ('sh_type', 1)
// CHECK-NEXT: ('sh_flags', 50)
// CHECK: # Section 0x00000005
// CHECK-NEXT: ('sh_name', 0x00000021) # '.rodata.str2.1'
// CHECK-NEXT: ('sh_type', 0x00000001)
// CHECK-NEXT: ('sh_flags', 0x00000032)
// CHECK-NEXT: ('sh_addr',
// CHECK-NEXT: ('sh_offset',
// CHECK-NEXT: ('sh_size', 16)
// CHECK-NEXT: ('sh_size', 0x00000010)
// CHECK-NEXT: ('sh_link',
// CHECK-NEXT: ('sh_info',
// CHECK-NEXT: ('sh_addralign', 1)
// CHECK-NEXT: ('sh_entsize', 2)
// CHECK-NEXT: ('sh_addralign', 0x00000001)
// CHECK-NEXT: ('sh_entsize', 0x00000002)
// CHECK: # Section 6
// CHECK-NEXT: ('sh_name', 48) # '.rodata.cst8
// CHECK-NEXT: ('sh_type', 1)
// CHECK-NEXT: ('sh_flags', 18)
// CHECK: # Section 0x00000006
// CHECK-NEXT: ('sh_name', 0x00000030) # '.rodata.cst8
// CHECK-NEXT: ('sh_type', 0x00000001)
// CHECK-NEXT: ('sh_flags', 0x00000012)
// CHECK-NEXT: ('sh_addr',
// CHECK-NEXT: ('sh_offset',
// CHECK-NEXT: ('sh_size', 16)
// CHECK-NEXT: ('sh_size', 0x00000010)
// CHECK-NEXT: ('sh_link',
// CHECK-NEXT: ('sh_info',
// CHECK-NEXT: ('sh_addralign', 1)
// CHECK-NEXT: ('sh_entsize', 8)
// CHECK-NEXT: ('sh_addralign', 0x00000001)
// CHECK-NEXT: ('sh_entsize', 0x00000008)

View File

@ -4,20 +4,20 @@
.file "foo"
foa:
// CHECK: # Symbol 1
// CHECK-NEXT: (('st_name', 1) # 'foo'
// CHECK-NEXT: ('st_bind', 0)
// CHECK-NEXT: ('st_type', 4)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 65521)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK: # Symbol 0x00000001
// CHECK-NEXT: (('st_name', 0x00000001) # 'foo'
// CHECK-NEXT: ('st_bind', 0x00000000)
// CHECK-NEXT: ('st_type', 0x00000004)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x0000fff1)
// CHECK-NEXT: ('st_value', 0x00000000)
// CHECK-NEXT: ('st_size', 0x00000000)
// CHECK-NEXT: ),
// CHECK-NEXT: # Symbol 2
// CHECK-NEXT: (('st_name', 5) # 'foa'
// CHECK-NEXT: ('st_bind', 0)
// CHECK-NEXT: ('st_type', 0)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 1)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK-NEXT: # Symbol 0x00000002
// CHECK-NEXT: (('st_name', 0x00000005) # 'foa'
// CHECK-NEXT: ('st_bind', 0x00000000)
// CHECK-NEXT: ('st_type', 0x00000000)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x00000001)
// CHECK-NEXT: ('st_value', 0x00000000)
// CHECK-NEXT: ('st_size', 0x00000000)

View File

@ -6,20 +6,20 @@
movl foo@GOT, %eax
movl foo@GOTPCREL(%rip), %eax
// CHECK: (('st_name', 5) # '_GLOBAL_OFFSET_TABLE_'
// CHECK-NEXT: ('st_bind', 1)
// CHECK: (('st_name', 0x00000005) # '_GLOBAL_OFFSET_TABLE_'
// CHECK-NEXT: ('st_bind', 0x00000001)
// CHECK: ('_relocations', [
// CHECK-NEXT: # Relocation 0
// CHECK-NEXT: # Relocation 0x00000000
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym',
// CHECK-NEXT: ('r_type', 3)
// CHECK-NEXT: ('r_type', 0x00000003)
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
// CHECK-NEXT: # Relocation 1
// CHECK-NEXT: # Relocation 0x00000001
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym',
// CHECK-NEXT: ('r_type', 9)
// CHECK-NEXT: ('r_type', 0x00000009)
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
// CHECK-NEXT: ])

View File

@ -7,24 +7,24 @@
foo:
// Section number 1 is .text
// CHECK: # Section 1
// CHECK-next: (('sh_name', 1) # '.text'
// CHECK: # Section 0x00000001
// CHECK-next: (('sh_name', 0x00000001) # '.text'
// Symbol number 2 is section number 1
// CHECK: # Symbol 2
// CHECK-NEXT: (('st_name', 0) # ''
// CHECK-NEXT: ('st_bind', 0)
// CHECK-NEXT: ('st_type', 3)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 1)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK: # Symbol 0x00000002
// CHECK-NEXT: (('st_name', 0x00000000) # ''
// CHECK-NEXT: ('st_bind', 0x00000000)
// CHECK-NEXT: ('st_type', 0x00000003)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x00000001)
// CHECK-NEXT: ('st_value', 0x00000000)
// CHECK-NEXT: ('st_size', 0x00000000)
// Relocation refers to symbol number 2
// CHECK: ('_relocations', [
// CHECK-NEXT: # Relocation 0
// CHECK-NEXT: # Relocation 0x00000000
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym', 2)
// CHECK-NEXT: ('r_sym', 0x00000002)
// CHECK-NEXT: ('r_type',
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),

View File

@ -23,75 +23,75 @@ zed:
foo:
// Section 4 is "sec1"
// CHECK: # Section 4
// CHECK-NEXT: (('sh_name', 18) # '.sec1'
// CHECK: # Section 0x00000004
// CHECK-NEXT: (('sh_name', 0x00000012) # '.sec1'
// Symbol number 1 is .Lfoo
// CHECK: # Symbol 1
// CHECK-NEXT: (('st_name', 1) # '.Lfoo'
// CHECK: # Symbol 0x00000001
// CHECK-NEXT: (('st_name', 0x00000001) # '.Lfoo'
// Symbol number 2 is foo
// CHECK: # Symbol 2
// CHECK-NEXT: (('st_name', 7) # 'foo'
// CHECK: # Symbol 0x00000002
// CHECK-NEXT: (('st_name', 0x00000007) # 'foo'
// Symbol number 6 is section 4
// CHECK: # Symbol 6
// CHECK-NEXT: (('st_name', 0) # ''
// CHECK-NEXT: ('st_bind', 0)
// CHECK-NEXT: ('st_type', 3)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 4)
// CHECK: # Symbol 0x00000006
// CHECK-NEXT: (('st_name', 0x00000000) # ''
// CHECK-NEXT: ('st_bind', 0x00000000)
// CHECK-NEXT: ('st_type', 0x00000003)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x00000004)
// Symbol number 8 is zed
// CHECK: # Symbol 8
// CHECK-NEXT: (('st_name', 11) # 'zed'
// CHECK: # Symbol 0x00000008
// CHECK-NEXT: (('st_name', 0x0000000b) # 'zed'
// Relocation 0 refers to symbol 1
// CHECK: ('_relocations', [
// CHECK-NEXT: # Relocation 0
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym', 1)
// CHECK-NEXT: ('r_type', 2
// CHECK-NEXT: ('r_sym', 0x00000001)
// CHECK-NEXT: ('r_type', 0x00000002
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
// Relocation 1 refers to symbol 6
// CHECK-NEXT: # Relocation 1
// CHECK-NEXT: # Relocation 0x00000001
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym', 6)
// CHECK-NEXT: ('r_type', 10)
// CHECK-NEXT: ('r_sym', 0x00000006)
// CHECK-NEXT: ('r_type', 0x0000000a)
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
// Relocation 2 refers to symbol 1
// CHECK-NEXT: # Relocation 2
// CHECK-NEXT: # Relocation 0x00000002
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym', 1)
// CHECK-NEXT: ('r_type', 10
// CHECK-NEXT: ('r_sym', 0x00000001)
// CHECK-NEXT: ('r_type', 0x0000000a
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
// Relocation 3 refers to symbol 2
// CHECK-NEXT: # Relocation 3
// CHECK-NEXT: # Relocation 0x00000003
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym', 2)
// CHECK-NEXT: ('r_type', 4
// CHECK-NEXT: ('r_sym', 0x00000002)
// CHECK-NEXT: ('r_type', 0x00000004
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
// Relocation 4 refers to symbol 2
// CHECK-NEXT: # Relocation 4
// CHECK-NEXT: # Relocation 0x00000004
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym', 2)
// CHECK-NEXT: ('r_type', 9
// CHECK-NEXT: ('r_sym', 0x00000002)
// CHECK-NEXT: ('r_type', 0x00000009
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
// Relocation 5 refers to symbol 8
// CHECK-NEXT: # Relocation 5
// CHECK-NEXT: (('r_offset', 35)
// CHECK-NEXT: ('r_sym', 8)
// CHECK-NEXT: ('r_type', 11)
// CHECK-NEXT: ('r_addend', 0)
// CHECK-NEXT: # Relocation 0x00000005
// CHECK-NEXT: (('r_offset', 0x00000023)
// CHECK-NEXT: ('r_sym', 0x00000008)
// CHECK-NEXT: ('r_type', 0x0000000b)
// CHECK-NEXT: ('r_addend', 0x00000000)
// CHECK-NEXT: ),
// CHECK-NEXT: ])

View File

@ -3,16 +3,16 @@
call bar
bar:
// CHECK: ('sh_name', 1) # '.text'
// CHECK-NEXT: ('sh_type', 1)
// CHECK-NEXT: ('sh_flags', 6)
// CHECK-NEXT: ('sh_addr', 0)
// CHECK-NEXT: ('sh_offset', 64)
// CHECK-NEXT: ('sh_size', 5)
// CHECK-NEXT: ('sh_link', 0)
// CHECK-NEXT: ('sh_info', 0)
// CHECK-NEXT: ('sh_addralign', 4)
// CHECK-NEXT: ('sh_entsize', 0)
// CHECK: ('sh_name', 0x00000001) # '.text'
// CHECK-NEXT: ('sh_type', 0x00000001)
// CHECK-NEXT: ('sh_flags', 0x00000006)
// CHECK-NEXT: ('sh_addr', 0x00000000)
// CHECK-NEXT: ('sh_offset', 0x00000040)
// CHECK-NEXT: ('sh_size', 0x00000005)
// CHECK-NEXT: ('sh_link', 0x00000000)
// CHECK-NEXT: ('sh_info', 0x00000000)
// CHECK-NEXT: ('sh_addralign', 0x00000004)
// CHECK-NEXT: ('sh_entsize', 0x00000000)
// CHECK-NEXT: ('_section_data', 'e8000000 00')
// CHECK-NOT: .rela.text
// CHECK: shstrtab

View File

@ -1,21 +1,21 @@
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | elf-dump | FileCheck %s
// CHECK: # Symbol 5
// CHECK-NEXT: (('st_name', 5) # 'baz'
// CHECK-NEXT: ('st_bind', 1)
// CHECK-NEXT: ('st_type', 0)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 0)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK: # Symbol 0x00000005
// CHECK-NEXT: (('st_name', 0x00000005) # 'baz'
// CHECK-NEXT: ('st_bind', 0x00000001)
// CHECK-NEXT: ('st_type', 0x00000000)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x00000000)
// CHECK-NEXT: ('st_value', 0x00000000)
// CHECK-NEXT: ('st_size', 0x00000000)
// CHECK-NEXT: ),
// CHECK: ('_relocations', [
// CHECK-NEXT: # Relocation 0
// CHECK-NEXT: (('r_offset', 12)
// CHECK-NEXT: ('r_sym', 5)
// CHECK-NEXT: ('r_type', 2)
// CHECK-NEXT: ('r_addend', 8)
// CHECK-NEXT: # Relocation 0x00000000
// CHECK-NEXT: (('r_offset', 0x0000000c)
// CHECK-NEXT: ('r_sym', 0x00000005)
// CHECK-NEXT: ('r_type', 0x00000002)
// CHECK-NEXT: ('r_addend', 0x00000008)
// CHECK-NEXT: ),
// CHECK-NEXT: ])

View File

@ -5,10 +5,10 @@
jmp foo@PLT
// CHECK: ('_relocations', [
// CHECK-NEXT: # Relocation 0
// CHECK-NEXT: # Relocation 0x00000000
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym',
// CHECK-NEXT: ('r_type', 4)
// CHECK-NEXT: ('r_type', 0x00000004)
// CHECK-NEXT: ('r_addend',
// CHECK-NEXT: ),
// CHECK-NEXT: ])

View File

@ -12,27 +12,27 @@ foo:
jmp bar
jmp foo
// CHECK: ('sh_name', 1) # '.text'
// CHECK-NEXT: ('sh_type', 1)
// CHECK-NEXT: ('sh_flags', 6)
// CHECK-NEXT: ('sh_addr', 0)
// CHECK-NEXT: ('sh_offset', 64)
// CHECK-NEXT: ('sh_size', 7)
// CHECK-NEXT: ('sh_link', 0)
// CHECK-NEXT: ('sh_info', 0)
// CHECK-NEXT: ('sh_addralign', 4)
// CHECK-NEXT: ('sh_entsize', 0)
// CHECK: ('sh_name', 0x00000001) # '.text'
// CHECK-NEXT: ('sh_type', 0x00000001)
// CHECK-NEXT: ('sh_flags', 0x00000006)
// CHECK-NEXT: ('sh_addr', 0x00000000)
// CHECK-NEXT: ('sh_offset', 0x00000040)
// CHECK-NEXT: ('sh_size', 0x00000007)
// CHECK-NEXT: ('sh_link', 0x00000000)
// CHECK-NEXT: ('sh_info', 0x00000000)
// CHECK-NEXT: ('sh_addralign', 0x00000004)
// CHECK-NEXT: ('sh_entsize', 0x00000000)
// CHECK-NEXT: ('_section_data', 'ebfee900 000000')
// CHECK: # Symbol 5
// CHECK-NEXT: (('st_name', 5) # 'foo'
// CHECK: # Symbol 0x00000005
// CHECK-NEXT: (('st_name', 0x00000005) # 'foo'
// CHECK: .rela.text
// CHECK: ('_relocations', [
// CHECK-NEXT: Relocation 0
// CHECK-NEXT: (('r_offset', 3)
// CHECK-NEXT: ('r_sym', 5)
// CHECK-NEXT: ('r_type', 2)
// CHECK-NEXT: ('r_addend', -4)
// CHECK-NEXT: Relocation 0x00000000
// CHECK-NEXT: (('r_offset', 0x00000003)
// CHECK-NEXT: ('r_sym', 0x00000005)
// CHECK-NEXT: ('r_type', 0x00000002)
// CHECK-NEXT: ('r_addend', 0xfffffffc)
// CHECK-NEXT: ),
// CHECK-NEXT: ])

View File

@ -4,50 +4,50 @@
// to .Lfoo uses the symbol and not the section.
// Section 3 is bss
// CHECK: # Section 3
// CHECK-NEXT: (('sh_name', 13) # '.bss'
// CHECK: # Section 0x00000003
// CHECK-NEXT: (('sh_name', 0x0000000d) # '.bss'
// CHECK: # Symbol 1
// CHECK-NEXT: (('st_name', 5) # '.Lfoo'
// CHECK: # Symbol 0x00000001
// CHECK-NEXT: (('st_name', 0x00000005) # '.Lfoo'
// Symbol 6 is section 3
// CHECK: # Symbol 6
// CHECK-NEXT: (('st_name', 0) # ''
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK-NEXT: ('st_bind', 0)
// CHECK-NEXT: ('st_type', 3)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 3)
// CHECK: # Symbol 0x00000006
// CHECK-NEXT: (('st_name', 0x00000000) # ''
// CHECK-NEXT: ('st_value', 0x00000000)
// CHECK-NEXT: ('st_size', 0x00000000)
// CHECK-NEXT: ('st_bind', 0x00000000)
// CHECK-NEXT: ('st_type', 0x00000003)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x00000003)
// CHECK: # Relocation 0
// CHECK-NEXT: (('r_offset', 2)
// CHECK-NEXT: ('r_sym', 1)
// CHECK-NEXT: ('r_type', 9)
// CHECK: # Relocation 0x00000000
// CHECK-NEXT: (('r_offset', 0x00000002)
// CHECK-NEXT: ('r_sym', 0x00000001)
// CHECK-NEXT: ('r_type', 0x00000009)
// CHECK-NEXT: ),
// CHECK-NEXT: # Relocation 1
// CHECK-NEXT: # Relocation 0x00000001
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym',
// CHECK-NEXT: ('r_type', 4)
// CHECK-NEXT: ('r_type', 0x00000004)
// CHECK-NEXT: ),
// CHECK-NEXT: # Relocation 2
// CHECK-NEXT: # Relocation 0x00000002
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym',
// CHECK-NEXT: ('r_type', 10)
// CHECK-NEXT: ('r_type', 0x0000000a)
// CHECK-NEXT: ),
// Relocation 3 (bar3@GOTOFF) is done with symbol 6 (bss)
// CHECK-NEXT: # Relocation 3
// CHECK-NEXT: # Relocation 0x00000003
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym', 6
// CHECK-NEXT: ('r_sym', 0x00000006
// CHECK-NEXT: ('r_type',
// CHECK-NEXT: ),
// Relocation 4 (bar2@GOT) is of type R_386_GOT32
// CHECK-NEXT: # Relocation 4
// CHECK-NEXT: # Relocation 0x00000004
// CHECK-NEXT: (('r_offset',
// CHECK-NEXT: ('r_sym',
// CHECK-NEXT: ('r_type', 3
// CHECK-NEXT: ('r_type', 0x00000003
// CHECK-NEXT: ),
.text

View File

@ -10,48 +10,48 @@ bar:
movq bar, %rdx // R_X86_64_32S
.long bar // R_X86_64_32
// CHECK: # Section 1
// CHECK: (('sh_name', 1) # '.text'
// CHECK: # Section 0x00000001
// CHECK: (('sh_name', 0x00000001) # '.text'
// CHECK: # Symbol 2
// CHECK: (('st_name', 0) # ''
// CHECK: ('st_bind', 0)
// CHECK ('st_type', 3)
// CHECK: ('st_other', 0)
// CHECK: ('st_shndx', 1)
// CHECK: # Symbol 0x00000002
// CHECK: (('st_name', 0x00000000) # ''
// CHECK: ('st_bind', 0x00000000)
// CHECK ('st_type', 0x00000003)
// CHECK: ('st_other', 0x00000000)
// CHECK: ('st_shndx', 0x00000001)
// CHECK: # Relocation 0
// CHECK-NEXT: (('r_offset', 1)
// CHECK-NEXT: ('r_sym', 2)
// CHECK-NEXT: ('r_type', 10)
// CHECK: # Relocation 0x00000000
// CHECK-NEXT: (('r_offset', 0x00000001)
// CHECK-NEXT: ('r_sym', 0x00000002)
// CHECK-NEXT: ('r_type', 0x0000000a)
// CHECK-NEXT: ('r_addend',
// CHECK: # Relocation 1
// CHECK-NEXT: (('r_offset', 8)
// CHECK-NEXT: ('r_sym', 2)
// CHECK-NEXT: ('r_type', 11)
// CHECK: # Relocation 0x00000001
// CHECK-NEXT: (('r_offset', 0x00000008)
// CHECK-NEXT: ('r_sym', 0x00000002)
// CHECK-NEXT: ('r_type', 0x0000000b)
// CHECK-NEXT: ('r_addend',
// CHECK: # Relocation 2
// CHECK-NEXT: (('r_offset', 19)
// CHECK-NEXT: ('r_sym', 2)
// CHECK-NEXT: ('r_type', 11)
// CHECK: # Relocation 0x00000002
// CHECK-NEXT: (('r_offset', 0x00000013)
// CHECK-NEXT: ('r_sym', 0x00000002)
// CHECK-NEXT: ('r_type', 0x0000000b)
// CHECK-NEXT: ('r_addend',
// CHECK: # Relocation 3
// CHECK-NEXT: (('r_offset', 26)
// CHECK-NEXT: ('r_sym', 2)
// CHECK-NEXT: ('r_type', 11)
// CHECK: # Relocation 0x00000003
// CHECK-NEXT: (('r_offset', 0x0000001a)
// CHECK-NEXT: ('r_sym', 0x00000002)
// CHECK-NEXT: ('r_type', 0x0000000b)
// CHECK-NEXT: ('r_addend',
// CHECK: # Relocation 4
// CHECK-NEXT: (('r_offset', 34)
// CHECK-NEXT: ('r_sym', 2)
// CHECK-NEXT: ('r_type', 11)
// CHECK: # Relocation 0x00000004
// CHECK-NEXT: (('r_offset', 0x00000022)
// CHECK-NEXT: ('r_sym', 0x00000002)
// CHECK-NEXT: ('r_type', 0x0000000b)
// CHECK-NEXT: ('r_addend',
// CHECK: # Relocation 5
// CHECK-NEXT: (('r_offset', 38)
// CHECK-NEXT: ('r_sym', 2)
// CHECK-NEXT: ('r_type', 10)
// CHECK: # Relocation 0x00000005
// CHECK-NEXT: (('r_offset', 0x00000026)
// CHECK-NEXT: ('r_sym', 0x00000002)
// CHECK-NEXT: ('r_type', 0x0000000a)
// CHECK-NEXT: ('r_addend',

View File

@ -6,6 +6,6 @@
.section .note.GNU-,"",@progbits
.section -.note.GNU,"",@progbits
// CHECK: ('sh_name', 18) # '.note.GNU-stack'
// CHECK: ('sh_name', 34) # '.note.GNU-'
// CHECK: ('sh_name', 45) # '-.note.GNU'
// CHECK: ('sh_name', 0x00000012) # '.note.GNU-stack'
// CHECK: ('sh_name', 0x00000022) # '.note.GNU-'
// CHECK: ('sh_name', 0x0000002d) # '-.note.GNU'

View File

@ -2,8 +2,8 @@
// Mostly a test that this doesn't crash anymore.
// CHECK: # Symbol 4
// CHECK-NEXT: (('st_name', 1) # 'foo'
// CHECK-NEXT: ('st_bind', 1)
// CHECK: # Symbol 0x00000004
// CHECK-NEXT: (('st_name', 0x00000001) # 'foo'
// CHECK-NEXT: ('st_bind', 0x00000001)
.size foo, .Lbar-foo

View File

@ -19,9 +19,9 @@ foo:
.sleb128 8193
// ELF_32: ('sh_name', 1) # '.text'
// ELF_32: ('sh_name', 0x00000001) # '.text'
// ELF_32: ('_section_data', '00017f3f 40c000bf 7fff3f80 4081c000')
// ELF_64: ('sh_name', 1) # '.text'
// ELF_64: ('sh_name', 0x00000001) # '.text'
// ELF_64: ('_section_data', '00017f3f 40c000bf 7fff3f80 4081c000')
// MACHO_32: ('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
// MACHO_32: ('_section_data', '00017f3f 40c000bf 7fff3f80 4081c000')

View File

@ -12,9 +12,9 @@ foo:
.uleb128 16383
.uleb128 16384
// ELF_32: ('sh_name', 1) # '.text'
// ELF_32: ('sh_name', 0x00000001) # '.text'
// ELF_32: ('_section_data', '00017f80 01ff7f80 8001')
// ELF_64: ('sh_name', 1) # '.text'
// ELF_64: ('sh_name', 0x00000001) # '.text'
// ELF_64: ('_section_data', '00017f80 01ff7f80 8001')
// MACHO_32: ('section_name', '__text\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
// MACHO_32: ('_section_data', '00017f80 01ff7f80 8001')

View File

@ -19,27 +19,27 @@
movsd .Lsym8(%rip), %xmm1
// CHECK: ('_symbols', [
// CHECK-NEXT: # Symbol 0
// CHECK-NEXT: (('st_name', 0) # ''
// CHECK: # Symbol 1
// CHECK-NEXT: (('st_name', 13) # '.Lsym8'
// CHECK: # Symbol 2
// CHECK-NEXT: (('st_name', 0) # ''
// CHECK: # Symbol 3
// CHECK-NEXT: (('st_name', 0) # ''
// CHECK: # Symbol 4
// CHECK-NEXT: (('st_name', 0) # ''
// CHECK: # Symbol 5
// CHECK-NEXT: (('st_name', 0) # ''
// CHECK: # Symbol 6
// CHECK-NEXT: (('st_name', 1) # '.Lsym1'
// CHECK: # Symbol 7
// CHECK-NEXT: (('st_name', 8) # 'sym6'
// CHECK-NEXT: ('st_bind', 1)
// CHECK-NEXT: ('st_type', 1)
// CHECK-NEXT: ('st_other', 0)
// CHECK-NEXT: ('st_shndx', 0)
// CHECK-NEXT: ('st_value', 0)
// CHECK-NEXT: ('st_size', 0)
// CHECK-NEXT: # Symbol 0x00000000
// CHECK-NEXT: (('st_name', 0x00000000) # ''
// CHECK: # Symbol 0x00000001
// CHECK-NEXT: (('st_name', 0x0000000d) # '.Lsym8'
// CHECK: # Symbol 0x00000002
// CHECK-NEXT: (('st_name', 0x00000000) # ''
// CHECK: # Symbol 0x00000003
// CHECK-NEXT: (('st_name', 0x00000000) # ''
// CHECK: # Symbol 0x00000004
// CHECK-NEXT: (('st_name', 0x00000000) # ''
// CHECK: # Symbol 0x00000005
// CHECK-NEXT: (('st_name', 0x00000000) # ''
// CHECK: # Symbol 0x00000006
// CHECK-NEXT: (('st_name', 0x00000001) # '.Lsym1'
// CHECK: # Symbol 0x00000007
// CHECK-NEXT: (('st_name', 0x00000008) # 'sym6'
// CHECK-NEXT: ('st_bind', 0x00000001)
// CHECK-NEXT: ('st_type', 0x00000001)
// CHECK-NEXT: ('st_other', 0x00000000)
// CHECK-NEXT: ('st_shndx', 0x00000000)
// CHECK-NEXT: ('st_value', 0x00000000)
// CHECK-NEXT: ('st_size', 0x00000000)
// CHECK-NEXT: ),
// CHECK-NEXT: ])

View File

@ -5,6 +5,6 @@
je .Lfoo
// CHECK: ('_symbols', [
// CHECK: (('st_name', 1) # '.Lfoo'
// CHECK-NEXT: ('st_bind', 1)
// CHECK: (('sh_name', 36) # '.strtab'
// CHECK: (('st_name', 0x00000001) # '.Lfoo'
// CHECK-NEXT: ('st_bind', 0x00000001)
// CHECK: (('sh_name', 0x00000024) # '.strtab'

View File

@ -9,22 +9,22 @@
.weak bar
bar:
//CHECK: # Symbol 4
//CHECK-NEXT: (('st_name', 5) # 'bar'
//CHECK-NEXT: ('st_bind', 2)
//CHECK-NEXT: ('st_type', 0)
//CHECK-NEXT: ('st_other', 0)
//CHECK-NEXT: ('st_shndx', 1)
//CHECK-NEXT: ('st_value', 0)
//CHECK-NEXT: ('st_size', 0)
//CHECK: # Symbol 0x00000004
//CHECK-NEXT: (('st_name', 0x00000005) # 'bar'
//CHECK-NEXT: ('st_bind', 0x00000002)
//CHECK-NEXT: ('st_type', 0x00000000)
//CHECK-NEXT: ('st_other', 0x00000000)
//CHECK-NEXT: ('st_shndx', 0x00000001)
//CHECK-NEXT: ('st_value', 0x00000000)
//CHECK-NEXT: ('st_size', 0x00000000)
//CHECK-NEXT: ),
//CHECK-NEXT: # Symbol 5
//CHECK: (('st_name', 1) # 'foo'
//CHECK-NEXT: ('st_bind', 2)
//CHECK-NEXT: ('st_type', 0)
//CHECK-NEXT: ('st_other', 0)
//CHECK-NEXT: ('st_shndx', 0)
//CHECK-NEXT: ('st_value', 0)
//CHECK-NEXT: ('st_size', 0)
//CHECK-NEXT: # Symbol 0x00000005
//CHECK: (('st_name', 0x00000001) # 'foo'
//CHECK-NEXT: ('st_bind', 0x00000002)
//CHECK-NEXT: ('st_type', 0x00000000)
//CHECK-NEXT: ('st_other', 0x00000000)
//CHECK-NEXT: ('st_shndx', 0x00000000)
//CHECK-NEXT: ('st_value', 0x00000000)
//CHECK-NEXT: ('st_size', 0x00000000)
//CHECK-NEXT: ),
//CHECK-NEXT: ])

View File

@ -3,14 +3,14 @@
.zero 4
.zero 1,42
// CHECK: ('sh_name', 1) # '.text'
// CHECK: ('sh_type', 1)
// CHECK: ('sh_flags', 6)
// CHECK: ('sh_addr', 0)
// CHECK: ('sh_offset', 64)
// CHECK: ('sh_size', 5)
// CHECK: ('sh_link', 0)
// CHECK: ('sh_info', 0)
// CHECK: ('sh_addralign', 4)
// CHECK: ('sh_entsize', 0)
// CHECK: ('sh_name', 0x00000001) # '.text'
// CHECK: ('sh_type', 0x00000001)
// CHECK: ('sh_flags', 0x00000006)
// CHECK: ('sh_addr', 0x00000000)
// CHECK: ('sh_offset', 0x00000040)
// CHECK: ('sh_size', 0x00000005)
// CHECK: ('sh_link', 0x00000000)
// CHECK: ('sh_info', 0x00000000)
// CHECK: ('sh_addralign', 0x00000004)
// CHECK: ('sh_entsize', 0x00000000)
// CHECK: ('_section_data', '00000000 2a')

View File

@ -11,3 +11,36 @@ def dataToHex(d):
hex_byte += ' '
bytes.append(hex_byte)
return ''.join(bytes).strip()
def dataToHexUnified(d):
""" Convert the raw data in 'd' to an hex string with a space every 4 bytes.
Each 4byte number is prefixed with 0x for easy sed/rx
Fixme: convert all MC tests to use this routine instead of the above
"""
bytes = []
for i,c in enumerate(d):
byte = ord(c)
hex_byte = hex(byte)[2:]
if byte <= 0xf:
hex_byte = '0' + hex_byte
if i % 4 == 0:
hex_byte = '0x' + hex_byte
if i % 4 == 3:
hex_byte += ' '
bytes.append(hex_byte)
return ''.join(bytes).strip()
def HexDump(val, numBits=32):
"""
1. do not print 'L'
2. Handle negatives and large numbers by mod (2^numBits)
3. print fixed length, prepend with zeros.
Length is exactly 2+(numBits/4)
4. Do print 0x Why?
so that they can be easily distinguished using sed/rx
"""
val = val & (( 1 << numBits) - 1)
newFmt = "0x%0" + "%d" % (numBits / 4) + "x"
return newFmt % val

View File

@ -6,6 +6,8 @@ import StringIO
import common_dump
FormatOutput=hex
class Reader:
def __init__(self, path):
if path == "-":
@ -77,16 +79,16 @@ class Section:
self.sh_entsize = f.readWord()
def dump(self, shstrtab, f, strtab, dumpdata):
print " (('sh_name', %d) # %r" % (self.sh_name, shstrtab[self.sh_name])
print " ('sh_type', %d)" % self.sh_type
print " ('sh_flags', %d)" % self.sh_flags
print " ('sh_addr', %d)" % self.sh_addr
print " ('sh_offset', %d)" % self.sh_offset
print " ('sh_size', %d)" % self.sh_size
print " ('sh_link', %d)" % self.sh_link
print " ('sh_info', %d)" % self.sh_info
print " ('sh_addralign', %d)" % self.sh_addralign
print " ('sh_entsize', %d)" % self.sh_entsize
print " (('sh_name', %s)" % common_dump.HexDump(self.sh_name), "# %r" % shstrtab[self.sh_name]
print " ('sh_type', %s)" % common_dump.HexDump(self.sh_type)
print " ('sh_flags', %s)" % common_dump.HexDump(self.sh_flags)
print " ('sh_addr', %s)" % common_dump.HexDump(self.sh_addr)
print " ('sh_offset', %s)" % common_dump.HexDump(self.sh_offset)
print " ('sh_size', %s)" % common_dump.HexDump(self.sh_size)
print " ('sh_link', %s)" % common_dump.HexDump(self.sh_link)
print " ('sh_info', %s)" % common_dump.HexDump(self.sh_info)
print " ('sh_addralign', %s)" % common_dump.HexDump(self.sh_addralign)
print " ('sh_entsize', %s)" % common_dump.HexDump(self.sh_entsize)
if self.sh_type == 2: # SHT_SYMTAB
print " ('_symbols', ["
dumpSymtab(f, self, strtab)
@ -106,20 +108,20 @@ def dumpSymtab(f, section, strtab):
for index in range(entries):
f.seek(section.sh_offset + index * section.sh_entsize)
print " # Symbol %d" % index
print " # Symbol %s" % common_dump.HexDump(index)
name = f.read32()
print " (('st_name', %d) # %r" % (name, strtab[name])
print " (('st_name', %s)" % common_dump.HexDump(name), "# %r" % strtab[name]
if not f.is64Bit:
print " ('st_value', %d)" % f.read32()
print " ('st_size', %d)" % f.read32()
print " ('st_value', %s)" % common_dump.HexDump(f.read32())
print " ('st_size', %s)" % common_dump.HexDump(f.read32())
st_info = f.read8()
print " ('st_bind', %d)" % (st_info >> 4)
print " ('st_type', %d)" % (st_info & 0xf)
print " ('st_other', %d)" % f.read8()
print " ('st_shndx', %d)" % f.read16()
print " ('st_bind', %s)" % common_dump.HexDump((st_info >> 4))
print " ('st_type', %s)" % common_dump.HexDump((st_info & 0xf))
print " ('st_other', %s)" % common_dump.HexDump(f.read8())
print " ('st_shndx', %s)" % common_dump.HexDump(f.read16())
if f.is64Bit:
print " ('st_value', %d)" % f.read64()
print " ('st_size', %d)" % f.read64()
print " ('st_value', %s)" % common_dump.HexDump(f.read64())
print " ('st_size', %s)" % common_dump.HexDump(f.read64())
print " ),"
def dumpRel(f, section, dumprela = False):
@ -127,17 +129,17 @@ def dumpRel(f, section, dumprela = False):
for index in range(entries):
f.seek(section.sh_offset + index * section.sh_entsize)
print " # Relocation %d" % index
print " (('r_offset', %d)" % f.readWord()
print " # Relocation %s" % common_dump.HexDump(index)
print " (('r_offset', %s)" % common_dump.HexDump(f.readWord())
r_info = f.readWord()
if f.is64Bit:
print " ('r_sym', %d)" % (r_info >> 32)
print " ('r_type', %d)" % (r_info & 0xffffffff)
print " ('r_sym', %s)" % common_dump.HexDump((r_info >> 32))
print " ('r_type', %s)" % common_dump.HexDump((r_info & 0xffffffff))
else:
print " ('r_sym', %d)" % (r_info >> 8)
print " ('r_type', %d)" % (r_info & 0xff)
print " ('r_sym', %s)" % common_dump.HexDump((r_info >> 8))
print " ('r_type', %s)" % common_dump.HexDump((r_info & 0xff))
if dumprela:
print " ('r_addend', %d)" % f.readWordS()
print " ('r_addend', %s)" % common_dump.HexDump(f.readWordS())
print " ),"
def dumpELF(path, opts):
@ -152,8 +154,8 @@ def dumpELF(path, opts):
elif fileclass == 2: # ELFCLASS64
f.is64Bit = True
else:
raise ValueError, "Unknown file class %d" % fileclass
print "('e_indent[EI_CLASS]', %d)" % fileclass
raise ValueError, "Unknown file class %s" % common_dump.HexDump(fileclass)
print "('e_indent[EI_CLASS]', %s)" % common_dump.HexDump(fileclass)
byteordering = f.read8()
if byteordering == 1: # ELFDATA2LSB
@ -161,32 +163,32 @@ def dumpELF(path, opts):
elif byteordering == 2: # ELFDATA2MSB
f.isLSB = False
else:
raise ValueError, "Unknown byte ordering %d" % byteordering
print "('e_indent[EI_DATA]', %d)" % byteordering
raise ValueError, "Unknown byte ordering %s" % common_dump.HexDump(byteordering)
print "('e_indent[EI_DATA]', %s)" % common_dump.HexDump(byteordering)
print "('e_indent[EI_VERSION]', %d)" % f.read8()
print "('e_indent[EI_OSABI]', %d)" % f.read8()
print "('e_indent[EI_ABIVERSION]', %d)" % f.read8()
print "('e_indent[EI_VERSION]', %s)" % common_dump.HexDump(f.read8())
print "('e_indent[EI_OSABI]', %s)" % common_dump.HexDump(f.read8())
print "('e_indent[EI_ABIVERSION]', %s)" % common_dump.HexDump(f.read8())
f.seek(16) # Seek to end of e_ident.
print "('e_type', %d)" % f.read16()
print "('e_machine', %d)" % f.read16()
print "('e_version', %d)" % f.read32()
print "('e_entry', %d)" % f.readWord()
print "('e_phoff', %d)" % f.readWord()
print "('e_type', %s)" % common_dump.HexDump(f.read16())
print "('e_machine', %s)" % common_dump.HexDump(f.read16())
print "('e_version', %s)" % common_dump.HexDump(f.read32())
print "('e_entry', %s)" % common_dump.HexDump(f.readWord())
print "('e_phoff', %s)" % common_dump.HexDump(f.readWord())
e_shoff = f.readWord()
print "('e_shoff', %d)" % e_shoff
print "('e_flags', %d)" % f.read32()
print "('e_ehsize', %d)" % f.read16()
print "('e_phentsize', %d)" % f.read16()
print "('e_phnum', %d)" % f.read16()
print "('e_shoff', %s)" % common_dump.HexDump(e_shoff)
print "('e_flags', %s)" % common_dump.HexDump(f.read32())
print "('e_ehsize', %s)" % common_dump.HexDump(f.read16())
print "('e_phentsize', %s)" % common_dump.HexDump(f.read16())
print "('e_phnum', %s)" % common_dump.HexDump(f.read16())
e_shentsize = f.read16()
print "('e_shentsize', %d)" % e_shentsize
print "('e_shentsize', %s)" % common_dump.HexDump(e_shentsize)
e_shnum = f.read16()
print "('e_shnum', %d)" % e_shnum
print "('e_shnum', %s)" % common_dump.HexDump(e_shnum)
e_shstrndx = f.read16()
print "('e_shstrndx', %d)" % e_shstrndx
print "('e_shstrndx', %s)" % common_dump.HexDump(e_shstrndx)
# Read all section headers
sections = []
@ -209,7 +211,7 @@ def dumpELF(path, opts):
print "('_sections', ["
for index in range(e_shnum):
print " # Section %d" % index
print " # Section %s" % common_dump.HexDump(index)
sections[index].dump(shstrtab, f, strtab, opts.dumpSectionData)
print "])"