This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
export data symbols as data on Win32
Previously on Win32 Perl, all the PL_* data symbols were treated as
function symbols with expectation of machine code at their targets when
generating the linking library perl5**.lib or perl5**.a. In VC Perl, if an
DLL XS module accidentally (by manipulating the defines before #including
perls headers) turned "extern __declspec(dllimport) I32 *PL_markstack_ptr;"
into "extern I32 *PL_markstack_ptr;", a SEGV would result as if the XS
module executed "I32 ax = (*(I32*)Perl_sv_2mortal)--;". By marking the
symbols as data in the linking lib, the VC linker will error out while
creating a XS DLL where this mistake of dropping out __declspec(dllimport)
happened, instead of a runtime crash. Mingw GCC linker does the correct
behavior, and does not treat the data symbol as machine code even if
"__declspec(dllimport)" is removed. Still add DATA to the GCC perldll.def
to be sure. There is no reason for "jmp" machine codestubs/thunks to
exist in the perl.lib/perl.a to a data export.
Also add constant folding to the loop in makedef.pl, since every other
platform check executes exactly once, there is no point of executing the
ops in the perl compile time constant folder vs runtime executing them.
If a data symbol name exceeds the 32 limit, then "DATA" will be catted onto
the symbol name and linking lib generation will fail since the symbol wont
exist. The 32 limit will then be increased at that point in the future.
See details about this patch in [perl #123626]