#12147: GHC's Linker Should Support Relocation Type 42 -------------------------------------+------------------------------------- Reporter: gershomb | Owner: Phyx- Type: bug | Status: patch Priority: high | Milestone: 8.0.2 Component: Runtime System | Version: 8.0.1 (Linker) | Resolution: | Keywords: Operating System: Linux | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2303 Wiki Page: | -------------------------------------+------------------------------------- Comment (by Phyx-): I haven't written a testcase since you need `binutils-2.26` for it to trigger and I don't think I can force the test only then. In any case, simplest case to reproduce this is to compile `GHC` with `DYNAMIC_GHC_PROGRAMS=NO` I use this assembly file as input: {{{ # x86_64 # as as_test.s -o as_test.o && objdump -Dr as_test.o # ghc --interactive hs_test as_test.o .text .globl foo foo: push %rbp mov %rsp, %rbp mov msg@GOTPCREL(%rip), %rdi call puts@PLT pop %rbp ret .data msg: .ascii "Hello World!\0" len = . - msg }}} Which with {{{ [phyx@localhost ~]$ as --version GNU assembler (GNU Binutils) 2.26.20160125 }}} returns the expected relocation {{{ [phyx@localhost ~]$ as as_test.s -o as_test.o && objdump -Dr as_test.o as_test.o: file format elf64-x86-64 Disassembly of section .text: 0000000000000000 <foo>: 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 48 8b 3d 00 00 00 00 mov 0x0(%rip),%rdi # b <foo+0xb> 7: R_X86_64_REX_GOTPCRELX msg-0x4 b: e8 00 00 00 00 callq 10 <foo+0x10> c: R_X86_64_PLT32 puts-0x4 10: 5d pop %rbp 11: c3 retq Disassembly of section .data: 0000000000000000 <msg>: 0: 48 rex.W 1: 65 6c gs insb (%dx),%es:(%rdi) 3: 6c insb (%dx),%es:(%rdi) 4: 6f outsl %ds:(%rsi),(%dx) 5: 20 57 6f and %dl,0x6f(%rdi) 8: 72 6c jb 76 <len+0x69> a: 64 21 00 and %eax,%fs:(%rax) }}} Before the patch it crashes as expected {{{ [phyx@localhost ~]$ ghc/inplace/bin/ghc-stage2 --interactive as_test.o hs_test.hs GHCi, version 8.1.20160604: http://www.haskell.org/ghc/ :? for help ghc-stage2: as_test.o: unhandled ELF relocation(RelA) type 42 linking extra libraries/objects failed }}} And after the patch {{{ GHCi, version 8.1.20160604: http://www.haskell.org/ghc/ :? for help [1 of 1] Compiling Main ( hs_test.hs, interpreted ) Ok, modules loaded: Main. *Main> main Hello World! }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/12147#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler