Error Cannot Represent Relocation Type Bfd_reloc_x86_64_32s
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up BFD_RELOC_64: Compiling assembler directives on a 32 bit linux with C++ up vote 0 down vote favorite I'm trying to compile the code below on a 32 bit Linux with GCC 4.4.1. #ifndef WIN32 #define DEBUG_STOP_POINT() \ asm ( " 0 : int3 ; " \ " .pushsection embed-breakpoints ; " \ " .quad 0b ; " \ " .popsection ; " ) #if defined ( _DEBUG ) && defined ( _ASPECT_DEBUG ) #define THROW_BREAKPOINT() \ asm ( " 0 : int3 ; " \ " .pushsection embed-breakpoints ; " \ " .quad 0b ; " \ " .popsection ; " ) #else #define THROW_BREAKPOINT() \ asm ( " 0 : .pushsection embed-breakpoints ; " \ " .quad 0b ; " \ " .popsection ; " ) #endif #else #define DEBUG_STOP_POINT() #define THROW_BREAKPOINT() #endif It was taken from a 64 bit project running on the 64 bit version of the same Linux where it compiles without problems with the same GCC 4.4.1. Every place where THROW_BREAKPOINT() (the DEBUG_STOP_POINT() is never used) is used issues the compile error: "cannot represent relocation type BFD_RELOC_64." And now the questions: What does this code ? These asm directives are 64 bit only ? Is so, could you, please, rewrite it in order to do the same thing on my 32 bit system (32 bit Intel Celeron M) ? May I suspect a compiler installation issue (the compiler and the required dependencies were installed from rpms on top of the existing and newer gcc using rpm -ivh --force options)? In this case, could you give me am example of code using asm directives which should compile on my 32 bit box ? What else may I try to fix the compile error (well, something different of using empty definitions as it is for the WIN32 case) ? c++ linux gcc assembly share|improve this question edited May 20 '14 at 21:43 Maxpm 7,1151163126 asked May 20 '14 at 21:33 AlainM 11 2 That's some damn heavy code. Are you writing your own OS? –Daniel Kamil Kozar May 20 '14 at 2
broken since April" Next in thread: Ken Moffat: "Re: i386 -> x86_64 cross compile failure (binutils bug?)" Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] I'm trying to build an x66-64 kernel on a 32 bit system (Ubuntu 5.10). I added -m64 to the CFLAGS as per the gcc docs. But http://stackoverflow.com/questions/23770351/bfd-reloc-64-compiling-assembler-directives-on-a-32-bit-linux-with-c the build fails with: $ make ARCH=x86_64 [...] CC init/initramfs.o CC init/calibrate.o LD init/built-in.o CHK usr/initramfs_list CC arch/x86_64/kernel/process.o CC arch/x86_64/kernel/signal.o AS arch/x86_64/kernel/entry.o arch/x86_64/kernel/entry.S: Assembler messages: arch/x86_64/kernel/entry.S:204: Error: cannot represent relocation type BFD_RELOC_X86_64_32S arch/x86_64/kernel/entry.S:275: Error: cannot represent relocation type BFD_RELOC_X86_64_32S arch/x86_64/kernel/entry.S:762: Error: cannot represent relocation type BFD_RELOC_X86_64_32S arch/x86_64/kernel/entry.S:815: http://lkml.iu.edu/hypermail/linux/kernel/0512.1/0492.html Error: cannot represent relocation type BFD_RELOC_X86_64_32S arch/x86_64/kernel/entry.S:536: Error: cannot represent relocation type BFD_RELOC_64 arch/x86_64/kernel/entry.S:536: Error: cannot represent relocation type BFD_RELOC_64 arch/x86_64/kernel/entry.S:785: Error: cannot represent relocation type BFD_RELOC_64 arch/x86_64/kernel/entry.S:785: Error: cannot represent relocation type BFD_RELOC_64 make[1]: *** [arch/x86_64/kernel/entry.o] Error 1 make: *** [arch/x86_64/kernel] Error 2 Is this a known toolchain bug? $ as --version GNU assembler 2.16.1 Debian GNU/Linux Lee - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ Next message: Andi Kleen: "Re: [PATCH 2.6.14] X86_64 delay resolution" Previous message: Steve Work: "[REPOST] Multi-thread corefiles broken since April" Next in thread: Ken Moffat: "Re: i386 -> x86_64 cross compile failure (binutils bug?)" Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[x] Bug17567 - RIP Relative Addressing fails on macho64 format Summary: RIP Relative Addressing fails on https://sourceware.org/bugzilla/show_bug.cgi?id=17567 macho64 format Status: NEW Alias: None Product: binutils Classification: Unclassified Component: gas (show other bugs) Version: 2.24 Importance: P2 normal Target Milestone: --- Assignee: Not yet assigned to anyone URL: Keywords: Depends on: Blocks: Reported: 2014-11-08 05:04 IST by Brandon Potter Modified: 2014-11-08 05:07 IST (History) CC List: 0 users See Also: Host: x86_64-apple-darwin14.0.0 Target: error cannot x86_64-apple-darwin14.0.0 Build: x86_64-apple-darwin14.0.0 Last reconfirmed: Attachments Add an attachment (proposed patch, testcase, etc.) Note You need to log in before you can comment on or make changes to this bug. Description Brandon Potter 2014-11-08 05:04:39 IST I am using binutils 2.24 to try to write a string to standard out of screen. Macho-64 does not support error cannot represent 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 ins