Repository navigation
Solaris ld raises reloc errors in JIT_WriteBarrier_Debug and ThePreStub #35154
Description
Activity
- addedarea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Apr 18, 2020 - addedos-SunOSSunOS, currently not officially supportedSunOS, currently not officially supportedand removedarea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
on Apr 18, 2020 jmp C_FUNC(JIT_WriteBarrier_Debug)andjmp C_FUNC(ThePreStub)are obviously causing this problem.Try compiling
extern void ThePreStub(); void Test() { ThePreStub(); }withgcc -fvisibility=hidden -O2 -S test.cand look at what thejmplooks like. The hand-written assembly should mimic that.This is the output from SmartOS x64:
$ echo "extern void ThePreStub(); void Test() { ThePreStub(); }" |\ gcc -x c -fvisibility=hidden -O2 -S - -o- |\ grep -B8 -A8 ThePreStub .LFB0: pushq %rbp .LCFI0: xorl %eax, %eax movq %rsp, %rbp .LCFI1: popq %rbp .LCFI2: jmp ThePreStub .LFE0: .size Test, .-Test .section .eh_frame,"a",@unwind .Lframe1: .long .LECIE1-.LSCIE1 .LSCIE1: .long 0 .byte 0x1
and on Ubuntu x64:
.p2align 4,,15 .globl Test .hidden Test .type Test, @function Test: .LFB0: .cfi_startproc xorl %eax, %eax jmp ThePreStub@PLT .cfi_endproc .LFE0: .size Test, .-Test .ident "GCC: (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0" .section .note.GNU-stack,"",@progbits
Hmm, this
jmp ThePreStublooks exactly like the one in the asm code.Maybe you can try to add a call to ThePreStub in tailcall position somewhere in the C/C++ code and see whether it links fine?
With -fPIC, this compiles fine on SmartOS and Ubuntu:
echo "int ThePreStub() {return 0;} int Test() { return ThePreStub(); } void Start() { Test(); }" \ | gcc -x c -fvisibility=hidden -shared -O2 -fPIC -
without -fPIC, it gives the same error on SmartOS but not on Ubuntu:
Text relocation remains referenced against symbol offset in file .text (section) 0x20 /var/tmp//ccFfambs.o .text (section) 0x38 /var/tmp//ccFfambs.o .text (section) 0x50 /var/tmp//ccFfambs.o ld: fatal: relocations remain against allocatable but non-writable sections collect2: error: ld returned 1 exit statusand we are compiling coreclr with -fPIC on both SmartOS and Ubuntu, so should be fine.
What is the output of
-Swith-fPIC? Is it different from the above?It adds
@PLTwith-fPIC:--- without_fPIC +++ with_fPIC @@ -13,7 +13,7 @@ .LCFI1: popq %rbp .LCFI2: - jmp ThePreStub + jmp ThePreStub@PLT .LFE0: .size Test, .-Test .section .eh_frame,"a",@unwind @@ -27,7 +27,7 @@ .sleb128 -8 .byte 0x10 .uleb128 0x1 - .byte 0x3 + .byte 0x1b .byte 0xc .uleb128 0x7 .uleb128 0x8 @@ -39,7 +39,7 @@ .long .LEFDE1-.LASFDE1 .LASFDE1: .long .LASFDE1-.Lframe1 - .long .LFB0 + .long .LFB0-. .long .LFE0-.LFB0 .uleb128 0 .byte 0x4
Does the error go away if you replace
jmp C_FUNC(ThePreStub)withjmp ThePreStub@PLTin unixasmhelpers.S ?I had some other undefined symbols errors due to missing SunOS linker options for
EXPORTS_FILE(-Mfor Illumos ld is similar as--version-filein GNU ld). Adding that linker options in few CMateLists.txt files automagically resolved this reloc issue. The build now succeeds on SmartOS without-mimpure-textoption.Thanks for your help @jkotas.
- ghost locked as resolved and limited conversation to collaborators
on Dec 9, 2020
When linking
libcoreclr.so, Solaris linker on SmartOS errors out as follow:I have workaround this error by using
-mimpure-text -Wl,-ztextofflinker flags.Is this an indication of something that can be fixed in the highlighted stubs?