Bug 23969 - PowerPC64 ELFv1 --defsym func1=func2 call to func1 errors
Summary: PowerPC64 ELFv1 --defsym func1=func2 call to func1 errors
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.32
: P2 normal
Target Milestone: ---
Assignee: Cary Coutant
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-12-09 13:42 UTC by Alan Modra
Modified: 2018-12-09 13:42 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Modra 2018-12-09 13:42:24 UTC
Running the gold testsuite plugin_test_defsym results in a segfault, due to the call to "bar" branching to the opd entry for "foo".  This isn't something specific to the plugin, just compiling the testcase with
powerpc64-linux-gcc -Bgcctestdir/ -g -O2 -o test_defsym -Wl,--defsym,bar=foo ~/src/binutils-gdb/gold/testsuite/plugin_test_defsym.c
results in a test_defsym binary with the error.

The problem is caused by gold defining --defsym symbols as constants.  Target_powerpc::symval_for_branch fails to detect such function symbols as being defined in a .opd section (only FROM_OBJECT symbols are supported), and therefore does not look up the code entry point in the function descriptor during relocation.  Even worse, --defsym symbols have value zero at the time Target::relax is called, so calls to symval_for_branch at that point cannot look up descriptors even if some other mechanism was devised for detecting symbols within .opd sections.  (Target::relax is where powerpc64 adds stubs for long branches and plt calls.)