Bug 14798 - gas mips target generates badly typed symbols
Summary: gas mips target generates badly typed symbols
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: gas (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-02 04:03 UTC by Rich Felker
Modified: 2012-11-02 04:03 UTC (History)
0 users

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 Rich Felker 2012-11-02 04:03:33 UTC
Symptom: failure of -Bsymbolic-functions to resolve libgcc references at link-time under certain circumstances. In particular, Sabotage Linux (https://github.com/rofl0r/sabotage) ends up building a broken musl libc.so on MIPS; its dynamic linker attempts to call libgcc functions before symbolic relocations have been processed.

Cause: When gcc generates calls to libgcc functions for long division, etc., it adds a .globl directive to the output asm for those functions. This is entirely unnecessary, but should be harmless. However, the mips target for gas, upon seeing a .globl directive, adds OBJECT type to the undefined symbol reference unless there is a .type directive. On other targets, the type remains UNKNOWN. This in turn prevents the linker's -Bsymbolic-functions option from resolving the symbol reference at link-time. Assuming libgcc was compiled correctly with visibility, these functions have hidden visibility and thus they get resolved at link time anyway; however, if libgcc was built with --disable-shared, they don't.

Really, this bug is an interaction of 3 separate issues in 3 pieces of software:

1. gcc: outputting useless .globl
2. gas mips target: treating .globl as implying type==OBJECT
3. libgcc: failure to use visibility when --disable-shared is specified

I believe at least numbers 2 and 3, and maybe all three of them, should be fixed, but only 2 pertains to binutils.