318 lines · plain
1// RUN: llvm-mc -triple x86_64-apple-darwin10 %s -filetype=obj -o - | llvm-readobj --file-headers -S --sd -r --symbols --macho-segment --macho-dysymtab --macho-indirect-symbols - | FileCheck %s2 3 .text4 5// FIXME: llvm-mc doesn't handle this in a way we can make compatible with 'as',6// currently, because of how we handle assembler variables.7//8// See <rdar://problem/7763719> improve handling of absolute symbols9 10// _baz = 411 12_foo:13 xorl %eax,%eax14_g0:15 xorl %eax,%eax16L0:17 jmp 418// jmp _baz19 20// FIXME: Darwin 'as' for historical reasons widens this jump, but doesn't emit21// a relocation. It seems like 'as' widens any jump that is not to a temporary,22// which is inherited from the x86_32 behavior, even though x86_64 could do23// better.24// jmp _g025 26 jmp L027 jmp _g128 29// FIXME: Darwin 'as' gets this wrong as well, even though it could get it right30// given the other things we do on x86_64. It is using a short jump here. This31// is probably fallout of the hack that exists for x86_32.32// jmp L133 34// FIXME: We don't support this, and would currently get it wrong, it should be a jump to an absolute address.35// jmp L0 - _g036 37// jmp _g1 - _g038// FIXME: Darwin 'as' comes up with 'SIGNED' here instead of 'BRANCH'.39// jmp _g1 - L140// FIXME: Darwin 'as' gets this completely wrong. It ends up with a single41// branch relocation. Fallout from the other delta hack?42// jmp L1 - _g043 44 jmp _g245 jmp L246 jmp _g347 jmp L348// FIXME: Darwin 'as' gets this completely wrong. It ends up with a single49// branch relocation. Fallout from the other delta hack?50// jmp L2 - _g351// jmp _g3 - _g252// FIXME: Darwin 'as' comes up with 'SIGNED' here instead of 'BRANCH'.53// jmp _g3 - L354// FIXME: Darwin 'as' gets this completely wrong. It ends up with a single55// branch relocation. Fallout from the other delta hack?56// jmp L3 - _g257 58 movl %eax,4(%rip)59// movl %eax,_baz(%rip)60 movl %eax,_g0(%rip)61 movl %eax,L0(%rip)62 movl %eax,_g1(%rip)63 movl %eax,L1(%rip)64 65// FIXME: Darwin 'as' gets most of these wrong, and there is an ambiguity in ATT66// syntax in what they should mean in the first place (absolute or67// rip-relative address).68// movl %eax,L0 - _g0(%rip)69// movl %eax,_g1 - _g0(%rip)70// movl %eax,_g1 - L1(%rip)71// movl %eax,L1 - _g0(%rip)72 73 movl %eax,_g2(%rip)74 movl %eax,L2(%rip)75 movl %eax,_g3(%rip)76 movl %eax,L3(%rip)77 78// FIXME: Darwin 'as' gets most of these wrong, and there is an ambiguity in ATT79// syntax in what they should mean in the first place (absolute or80// rip-relative address).81// movl %eax,L2 - _g2(%rip)82// movl %eax,_g3 - _g2(%rip)83// movl %eax,_g3 - L3(%rip)84// movl %eax,L3 - _g2(%rip)85 86_g1:87 xorl %eax,%eax88L1:89 xorl %eax,%eax90 91 .data92_g2:93 xorl %eax,%eax94L2:95 .quad 496// .quad _baz97 .quad _g298 .quad L299 .quad _g3100 .quad L3101 .quad L2 - _g2102 .quad _g3 - _g2103 .quad L3 - _g2104 .quad L3 - _g3105 106 .quad _g0107 .quad L0108 .quad _g1109 .quad L1110 .quad L0 - _g0111 .quad _g1 - _g0112 .quad L1 - _g0113 .quad L1 - _g1114 115_g3:116 xorl %eax,%eax117L3:118 xorl %eax,%eax119 120// FIXME: Unfortunately, we do not get these relocations in exactly the same121// order as Darwin 'as'. It turns out that 'as' *usually* ends up emitting122// them in reverse address order, but sometimes it allocates some123// additional relocations late so these end up precede the other entries. I124// haven't figured out the exact criteria for this yet.125 126// CHECK: File: <stdin>127// CHECK: Format: Mach-O 64-bit x86-64128// CHECK: Arch: x86_64129// CHECK: AddressSize: 64bit130// CHECK: MachHeader {131// CHECK: Magic: Magic64 (0xFEEDFACF)132// CHECK: CpuType: X86-64 (0x1000007)133// CHECK: CpuSubType: CPU_SUBTYPE_X86_64_ALL (0x3)134// CHECK: FileType: Relocatable (0x1)135// CHECK: NumOfLoadCommands: 4136// CHECK: SizeOfLoadCommands: 352137// CHECK: Flags [ (0x0)138// CHECK: ]139// CHECK: Reserved: 0x0140// CHECK: }141// CHECK: Sections [142// CHECK: Section {143// CHECK: Index: 0144// CHECK: Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00)145// CHECK: Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)146// CHECK: Address: 0x0147// CHECK: Size: 0x5E148// CHECK: Offset: 384149// CHECK: Alignment: 0150// CHECK: RelocationOffset: 0x270151// CHECK: RelocationCount: 12152// CHECK: Type: Regular (0x0)153// CHECK: Attributes [ (0x800004)154// CHECK: PureInstructions (0x800000)155// CHECK: SomeInstructions (0x4)156// CHECK: ]157// CHECK: Reserved1: 0x0158// CHECK: Reserved2: 0x0159// CHECK: Reserved3: 0x0160// CHECK: SectionData (161// CHECK: 0000: 31C031C0 E9040000 00EBF9E9 00000000 |1.1.............|162// CHECK: 0010: E9000000 00E90200 0000E900 000000E9 |................|163// CHECK: 0020: 02000000 89050400 00008905 D2FFFFFF |................|164// CHECK: 0030: 8905CEFF FFFF8905 00000000 89050200 |................|165// CHECK: 0040: 00008905 00000000 89050200 00008905 |................|166// CHECK: 0050: 00000000 89050200 000031C0 31C0 |..........1.1.|167// CHECK: )168// CHECK: }169// CHECK: Section {170// CHECK: Index: 1171// CHECK: Name: __data (5F 5F 64 61 74 61 00 00 00 00 00 00 00 00 00 00)172// CHECK: Segment: __DATA (5F 5F 44 41 54 41 00 00 00 00 00 00 00 00 00 00)173// CHECK: Address: 0x5E174// CHECK: Size: 0x8E175// CHECK: Offset: 478176// CHECK: Alignment: 0177// CHECK: RelocationOffset: 0x2D0178// CHECK: RelocationCount: 16179// CHECK: Type: Regular (0x0)180// CHECK: Attributes [ (0x4)181// CHECK: SomeInstructions (0x4)182// CHECK: ]183// CHECK: Reserved1: 0x0184// CHECK: Reserved2: 0x0185// CHECK: Reserved3: 0x0186// CHECK: SectionData (187// CHECK: 0000: 31C00400 00000000 00000000 00000000 |1...............|188// CHECK: 0010: 00000200 00000000 00000000 00000000 |................|189// CHECK: 0020: 00000200 00000000 00000200 00000000 |................|190// CHECK: 0030: 00000000 00000000 00000200 00000000 |................|191// CHECK: 0040: 00000200 00000000 00000000 00000000 |................|192// CHECK: 0050: 00000200 00000000 00000000 00000000 |................|193// CHECK: 0060: 00000200 00000000 00000200 00000000 |................|194// CHECK: 0070: 00000000 00000000 00000200 00000000 |................|195// CHECK: 0080: 00000200 00000000 000031C0 31C0 |..........1.1.|196// CHECK: )197// CHECK: }198// CHECK: ]199// CHECK: Relocations [200// CHECK: Section __text {201// CHECK: 0x56 1 2 1 X86_64_RELOC_SIGNED 0 _g3202// CHECK: 0x50 1 2 1 X86_64_RELOC_SIGNED 0 _g3203// CHECK: 0x4A 1 2 1 X86_64_RELOC_SIGNED 0 _g2204// CHECK: 0x44 1 2 1 X86_64_RELOC_SIGNED 0 _g2205// CHECK: 0x3E 1 2 1 X86_64_RELOC_SIGNED 0 _g1206// CHECK: 0x38 1 2 1 X86_64_RELOC_SIGNED 0 _g1207// CHECK: 0x20 1 2 1 X86_64_RELOC_BRANCH 0 _g3208// CHECK: 0x1B 1 2 1 X86_64_RELOC_BRANCH 0 _g3209// CHECK: 0x16 1 2 1 X86_64_RELOC_BRANCH 0 _g2210// CHECK: 0x11 1 2 1 X86_64_RELOC_BRANCH 0 _g2211// CHECK: 0xC 1 2 1 X86_64_RELOC_BRANCH 0 _g1212// CHECK: 0x5 1 2 1 X86_64_RELOC_BRANCH 0 _foo213// CHECK: }214// CHECK: Section __data {215// CHECK: 0x7A 0 3 1 X86_64_RELOC_SUBTRACTOR 0 _g0216// CHECK: 0x7A 0 3 1 X86_64_RELOC_UNSIGNED 0 _g1217// CHECK: 0x72 0 3 1 X86_64_RELOC_SUBTRACTOR 0 _g0218// CHECK: 0x72 0 3 1 X86_64_RELOC_UNSIGNED 0 _g1219// CHECK: 0x62 0 3 1 X86_64_RELOC_UNSIGNED 0 _g1220// CHECK: 0x5A 0 3 1 X86_64_RELOC_UNSIGNED 0 _g1221// CHECK: 0x52 0 3 1 X86_64_RELOC_UNSIGNED 0 _g0222// CHECK: 0x4A 0 3 1 X86_64_RELOC_UNSIGNED 0 _g0223// CHECK: 0x3A 0 3 1 X86_64_RELOC_SUBTRACTOR 0 _g2224// CHECK: 0x3A 0 3 1 X86_64_RELOC_UNSIGNED 0 _g3225// CHECK: 0x32 0 3 1 X86_64_RELOC_SUBTRACTOR 0 _g2226// CHECK: 0x32 0 3 1 X86_64_RELOC_UNSIGNED 0 _g3227// CHECK: 0x22 0 3 1 X86_64_RELOC_UNSIGNED 0 _g3228// CHECK: 0x1A 0 3 1 X86_64_RELOC_UNSIGNED 0 _g3229// CHECK: 0x12 0 3 1 X86_64_RELOC_UNSIGNED 0 _g2230// CHECK: 0xA 0 3 1 X86_64_RELOC_UNSIGNED 0 _g2231// CHECK: }232// CHECK: ]233// CHECK: Symbols [234// CHECK: Symbol {235// CHECK: Name: _foo (1)236// CHECK: Type: Section (0xE)237// CHECK: Section: __text (0x1)238// CHECK: RefType: UndefinedNonLazy (0x0)239// CHECK: Flags [ (0x0)240// CHECK: ]241// CHECK: Value: 0x0242// CHECK: }243// CHECK: Symbol {244// CHECK: Name: _g0 (18)245// CHECK: Type: Section (0xE)246// CHECK: Section: __text (0x1)247// CHECK: RefType: UndefinedNonLazy (0x0)248// CHECK: Flags [ (0x0)249// CHECK: ]250// CHECK: Value: 0x2251// CHECK: }252// CHECK: Symbol {253// CHECK: Name: _g1 (14)254// CHECK: Type: Section (0xE)255// CHECK: Section: __text (0x1)256// CHECK: RefType: UndefinedNonLazy (0x0)257// CHECK: Flags [ (0x0)258// CHECK: ]259// CHECK: Value: 0x5A260// CHECK: }261// CHECK: Symbol {262// CHECK: Name: _g2 (10)263// CHECK: Type: Section (0xE)264// CHECK: Section: __data (0x2)265// CHECK: RefType: UndefinedNonLazy (0x0)266// CHECK: Flags [ (0x0)267// CHECK: ]268// CHECK: Value: 0x5E269// CHECK: }270// CHECK: Symbol {271// CHECK: Name: _g3 (6)272// CHECK: Type: Section (0xE)273// CHECK: Section: __data (0x2)274// CHECK: RefType: UndefinedNonLazy (0x0)275// CHECK: Flags [ (0x0)276// CHECK: ]277// CHECK: Value: 0xE8278// CHECK: }279// CHECK: ]280// CHECK: Indirect Symbols {281// CHECK: Number: 0282// CHECK: Symbols [283// CHECK: ]284// CHECK: }285// CHECK: Segment {286// CHECK: Cmd: LC_SEGMENT_64287// CHECK: Name: 288// CHECK: Size: 232289// CHECK: vmaddr: 0x0290// CHECK: vmsize: 0xEC291// CHECK: fileoff: 384292// CHECK: filesize: 236293// CHECK: maxprot: rwx294// CHECK: initprot: rwx295// CHECK: nsects: 2296// CHECK: flags: 0x0297// CHECK: }298// CHECK: Dysymtab {299// CHECK: ilocalsym: 0300// CHECK: nlocalsym: 5301// CHECK: iextdefsym: 5302// CHECK: nextdefsym: 0303// CHECK: iundefsym: 5304// CHECK: nundefsym: 0305// CHECK: tocoff: 0306// CHECK: ntoc: 0307// CHECK: modtaboff: 0308// CHECK: nmodtab: 0309// CHECK: extrefsymoff: 0310// CHECK: nextrefsyms: 0311// CHECK: indirectsymoff: 0312// CHECK: nindirectsyms: 0313// CHECK: extreloff: 0314// CHECK: nextrel: 0315// CHECK: locreloff: 0316// CHECK: nlocrel: 0317// CHECK: }318