Subject: | Support compile-time usage with perlcc |
See remap-symname pull request (nee the RT # id first).
Extend Encode_XSEncoding for the symbol name.
Store the symbol name along the IV ptr as SVp_POK PVX.
This is needed for perlcc when thawing frozen images, where an encoding object was initialized at compile-time, pointing to an extern symbol of the shared library, and need to be remapped to the new ptr at run-time.
See e.g. https://rt.cpan.org/Public/Bug/Display.html?id=94069
where Net::DNS uses an encoding via use constant, causing a segfault,
and https://code.google.com/p/perl-compiler/issues/detail?id=305 for
the perlcc support code.
Which is something along:
#include <dlfcn.h>
void *handle = dlopen(sofile, RTLD_NOW|RTLD_NOLOAD);
void *ascii_encoding = dlsym(handle, "ascii_encoding");
SvIV_set(&sv_list[1], PTR2IV(ascii_encoding));
perlcc Detection:
https://github.com/rurban/perl-compiler/blob/ce6ce452dd8fcc9bb90605dcf47489250fd540a1/lib/B/C.pm#L2545
Remapping:
https://github.com/rurban/perl-compiler/blob/ce6ce452dd8fcc9bb90605dcf47489250fd540a1/lib/B/C.pm#L4851