-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix trampoline on PPC #38980
Fix trampoline on PPC #38980
Conversation
@staticfloat I added an error check to the initialization and surprisingly it get's triggered on aarch64/macos/windows
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you recall what you based the original implementation on?
Keno and I were mimicking the PLT disassembly from other projects, such as libgit2.so
:
$ objdump -d libgit2.so | grep -E "^[0-9a-f]+.*plt_call.*:" -A 4 | head
0000000000016400 <0000001b.plt_call.__gmon_start__>:
16400: 18 00 41 f8 std r2,24(r1)
16404: 60 8b 82 e9 ld r12,-29856(r2)
16408: a6 03 89 7d mtctr r12
1640c: 20 04 80 4e bctr
That being said, our method of calculating the pointer value was haphazard and we went with the first reasonable thing that compiled and seemed to work. I trust your tests more than what we put together, but perhaps if @Keno takes a look, he'll have an opinion.
I added an error check to the initialization and surprisingly it get's triggered on aarch64/macos/windows
If I'm reading this properly, this is because jl_compile_extern_c
is incompletely exported; it appears in jl_exported_funcs.inc
and yet is not marked as JL_DLLEXPORT
in julia.h
, it's only declared in julia_internal.h
. Man, it's almost like whoever wrote jl_exported_funcs.inc
had no idea what they were doing..... ;)
c5197f6
to
47546b5
Compare
Fair enough, the linker actually optimizes the toc lookup I wrote to something that looks very similar to what you wrote, so I suspect we only needed the global entry point and remove the store of the This actually raises another point. The code I encountered this on was Line 240 in 46487ae
|
@staticfloat My check seems to conservative :)
|
CI is unhappy with this |
1. Add global entry 2. Don't store `r2` on parent frame 3. Conservative load from toc
91c4900
to
ff4135b
Compare
I split out the verification into a separate draft PR #38994, since that is orthogonal to this PR. |
* [Make] Normalize ppc64le to powerpc64le * [CLI] Fix trampoline on PowerPC 1. Add global entry 2. Don't store `r2` on parent frame 3. Conservative load from toc * remove jl_compile_extern_c from exported funcs (cherry picked from commit 29d5d60)
* [Make] Normalize ppc64le to powerpc64le * [CLI] Fix trampoline on PowerPC 1. Add global entry 2. Don't store `r2` on parent frame 3. Conservative load from toc * remove jl_compile_extern_c from exported funcs (cherry picked from commit 29d5d60)
* [Make] Normalize ppc64le to powerpc64le * [CLI] Fix trampoline on PowerPC 1. Add global entry 2. Don't store `r2` on parent frame 3. Conservative load from toc * remove jl_compile_extern_c from exported funcs
* [Make] Normalize ppc64le to powerpc64le * [CLI] Fix trampoline on PowerPC 1. Add global entry 2. Don't store `r2` on parent frame 3. Conservative load from toc * remove jl_compile_extern_c from exported funcs (cherry picked from commit 29d5d60)
In my earlier tests I was checking on a machine with
powepc64le
as arch, thus us skipping the inclusion of trampolines.yields
So the important changes I made were:
r2
correctlyr2
Things that confuse me:
but I observed that the pointer obtained is already the correct one
std 2,24(1); \
which is odd, since IIUC it's optional but including it caused segmentation faults down the line.This passes tests on my development machine.
@staticfloat do you recall what you based the original implementation on?
cc: @xorJane