Bug 31171 - ld generates gratuitous PLT entries on ARM
Summary: ld generates gratuitous PLT entries on ARM
Status: UNCONFIRMED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-12-15 22:38 UTC by Rich Felker
Modified: 2023-12-15 22:48 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 Rich Felker 2023-12-15 22:38:35 UTC
This looks like it may be the same as https://sourceware.org/bugzilla/show_bug.cgi?id=22374 for other archs. I was testing with the program:

#include <stdlib.h>
static void (*f)() = abort;
int main() {
	return (long)f;
}

built with -O0 so there's no attempt at determining that f doesn't change and inlining it. The emitted asm and .o file clearly do not contain any references to abort from .text; however, the linked executable has JUMP_SLOT relocations and abort@plt instructions.

Both 32-bit arm and aarch64 are affected.

The condition for generating a PLT entry (and analogously, for data, a copy relocation) should be that the symbol is referenced from text, not that it's a function-type symbol being referenced at all. References from data do not need PLT entries or copy relocations.