t/porting/libperl.t: fix issue with common symbols #22586
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Test 5 was failing on newer Linux builds with clang and ASAN.
This was indirectly because although since around 2020 both gcc and clang have -fno-common by default, clang+ASAN was putting some private symbols in the common section of the libperl object file while under -fno-cpmmon, namely this output from nm:
It so happens that libperl.t handled -fno-common by aliasing a hash, $symbols{data}{common}{}, to another hash, $symbols{data}{bss}{} if {common} was empty. It then looked up a particular symbol under {common} and found it even if it was actually under {bss}. This scheme failed as soon as {common} was non-empty even under -fno-common.
This commit removes the common-to-bss aliasing trick and instead looks for the symbol under both common and bss. The test passes if either is found.
This commit also changes the test diagnostic output accordingly. It also now recognises (but ignores) 'w' and 'W' weak symbol types in nm output, such as
TODO: fill description here