Bug 108541

Summary: Convert x86 assembly stub to PIC to fix linking with lld
Product: Mesa Reporter: Christian Weisgerber <naddy>
Component: Mesa coreAssignee: mesa-dev
Status: RESOLVED MOVED QA Contact: mesa-dev
Severity: normal    
Priority: medium    
Version: unspecified   
Hardware: Other   
OS: OpenBSD   
Whiteboard:
i915 platform: i915 features:
Attachments: Convert entry_x86_tsd.h to PIC
adapted libglvnd x86 tsd changes

Description Christian Weisgerber 2018-10-24 17:38:19 UTC
Created attachment 142177 [details] [review]
Convert entry_x86_tsd.h to PIC

The x86 assembly language stub in src/mapi/entry_x86_tsd.h does not generate PIC (position-independent code). This causes text relocations, which are by default treated as an error by LLVM's lld linker (now used by FreeBSD and OpenBSD) when building a shared library.

/usr/bin/ld: error: can't create dynamic relocation R_386_32 against symbol: _glapi_Dispatch in readonly segment; recompile object files with -fPIC
>>> defined in .libs/shared_glapi_libglapi_la-u_current.o
>>> referenced by entry.c
>>>               .libs/shared_glapi_libglapi_la-entry.o:(.text+0x1)

The accompanying minimal diff remedies this by generating PIC code.  This is mostly copied from the neighboring entry_x86_tls.h.
Comment 1 Jonathan Gray 2018-10-31 06:48:23 UTC
Created attachment 142297 [details] [review]
adapted libglvnd x86 tsd changes
Comment 2 Jonathan Gray 2018-10-31 06:51:00 UTC
Your patch segfaults at runtime, an approach based on libglvnd x86 tsd changes seems to work however.

https://github.com/NVIDIA/libglvnd/commit/9a17198be3622ffa00f9db36e6b55773d4dcf596#diff-ac251356bcfe8971786926ffc9660d69
Comment 3 ytht.net 2019-09-13 17:24:25 UTC
FYI, I create a merge request on behalf of Jonathan Gray:

https://gitlab.freedesktop.org/mesa/mesa/merge_requests/1974
Comment 4 GitLab Migration User 2019-09-18 20:27:26 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/mesa/mesa/issues/1032.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.