https://sourceware.org/bugzilla/show_bug.cgi?id=17567
Bug ID: 17567 Summary: RIP Relative Addressing fails on macho64 format Product: binutils Version: 2.24 Status: NEW Severity: normal Priority: P2 Component: gas Assignee: unassigned at sourceware dot org Reporter: bmpotter13 at gmail dot com I am using binutils 2.24 to try to write a string to standard out of screen. Macho-64 does not support assignment of 32 bit absolute addresses. A working solution is to use RIP relative addressing. Using the following: movq msg, %rdi ... msg: .ascii "Hello\n" it generates the error "write64bit.s:6: Error: cannot represent relocation type BFD_RELOC_X86_64_32S" while the following leaq msg(%rip), %rdi ... msg: .ascii "Hello\n" generates no errors, assembles, and links without errors. Using 2.24 'as', this produces "leaq 0x0(%rip), %rdi" rather than "leaq 0x13(%rip), %rdi" as shown from the objdump disassembly. Disassembly of section .text: 0000000000001fcd <_main>: 1fcd: b8 04 00 00 02 mov $0x2000004,%eax 1fd2: 48 c7 c7 01 00 00 00 mov $0x1,%rdi 1fd9: 48 8d 35 00 00 00 00 lea 0x0(%rip),%rsi # 1fe0 <_main+0x13> 1fe0: 48 c7 c2 0d 00 00 00 mov $0xd,%rdx 1fe7: 0f 05 syscall 1fe9: b8 01 00 00 02 mov $0x2000001,%eax 1fee: 48 31 ff xor %rdi,%rdi 1ff1: 0f 05 syscall The source code assembles correctly using the 1.38 provided by Xcode. I compiled from source using: ~/Downloads/binutils-2.24/configure --disable-werror make ~/Downloads/binutils-2.24/gas/configure make sudo make install Assembled and linked with as -o write64bit.o write64bit.s ld -lSystem -macosx_version_min 10.10 -o write64bit write64bit.o write64bit.s source code .global _main _main: movl $0x2000004, %eax movq $1, %rdi leaq msg(%rip), %rsi movq $0xd, %rdx syscall movl $0x2000001, %eax xorq %rdi, %rdi syscall msg: .ascii "Hello world!\n" -- You are receiving this mail because: You are on the CC list for the bug. _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org https://lists.gnu.org/mailman/listinfo/bug-binutils