On Mon, 13 Nov 2023 07:46:37 GMT, Jorn Vernee <jver...@openjdk.org> wrote:

>>> For some context: `java.lang.foreign.Linker.nativeLinker().defaultLookup()` 
>>> returns a `SymbolLookup` that can be used to find symbols from the standard 
>>> library.
>>> 
>>> We use a shim library that re-exports symbols from the standard library in 
>>> order to make them accessible through `dlsym`, since on e.g. Linux the 
>>> standard library .so files might actually be linker scripts which we don't 
>>> want to mess with. On Windows we use ucrtbase.dll + an auxiliary library 
>>> that contains the expansions of several 'inline' functions such as 
>>> `printf`. I'm not surprised to see that another platform like AIX requires 
>>> more to make this work as well.
>>> 
>>> That said, I think we should limit the exported symbols to only those found 
>>> in the standard C library header files: 
>>> https://en.cppreference.com/w/c/header
>> 
>> Currently the symbols are restricted to some parts of libc and the entire 
>> math library libm. 
>> Are you suggesting we restrict the list to common math functions such as 
>> https://en.cppreference.com/w/c/numeric/math ?
>
>> > That said, I think we should limit the exported symbols to only those 
>> > found in the standard C library header files: 
>> > https://en.cppreference.com/w/c/header
>> 
>> Currently the symbols are restricted to some parts of libc and the entire 
>> math library libm. Are you suggesting we restrict the list to common math 
>> functions such as https://en.cppreference.com/w/c/numeric/math ?
> 
> I'm suggesting to include things that are defined by the C standard, plus 
> some platform specific extensions. i.e. limit this to what is considered part 
> of the public/supported API of the standard library on AIX.

@JornVernee when I googled for "dlsym equivalent for static libraries it turned 
up BFD:
https://stackoverflow.com/questions/10279693/dlsym-like-behaviour-for-static-linked-libraries
https://ftp.gnu.org/old-gnu/Manuals/bfd-2.9.1/html_chapter/bfd_1.html
but it seems ancient.

Maybe AIX, given it seems to like/prefer static linking, also provides some 
tools in this area?

-------------

PR Comment: https://git.openjdk.org/jdk/pull/16414#issuecomment-1809550596

Reply via email to