[go] cmd/link: don't create __x86.get_pc_thunk symbol if it already exists

1 view
Skip to first unread message

David Chase (Gerrit)

unread,
Dec 15, 2025, 4:08:24 PM (19 hours ago) Dec 15
to Cherry Mui, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Go LUCI, Ian Lance Taylor, golang-co...@googlegroups.com

David Chase submitted the change with unreviewed changes

Unreviewed changes

1 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: src/cmd/link/internal/x86/asm.go
Insertions: 1, Deletions: 1.

@@ -72,7 +72,7 @@
{"di", 7},
} {
thunkfunc := ldr.CreateSymForUpdate("__x86.get_pc_thunk."+r.name, 0)
- if thunkfunc.Type() != 0 {
+ if t := thunkfunc.Type(); t != 0 && t != sym.SXREF && t != sym.SDYNIMPORT && t != sym.SUNDEFEXT {
continue // symbol already exists, probably loaded from a C object
}
thunkfunc.SetType(sym.STEXT)
```

Change information

Commit message:
cmd/link: don't create __x86.get_pc_thunk symbol if it already exists

On 386, in some build modes we need to create the __x86.get_pc_thunk
symbols, to support PC-relative addressing. In some situation
the thunk symbols may already exist, e.g. loaded from a C object
in internal linking mode. In this case, we should use the exiting
symbol instead of making a new one. The current code updates the
symbol content in place but also adds a duplicated entry to Textp,
which breaks the address sorting order.

Fixes #76815.
Change-Id: Iab11106ce592dc5219b7a0e07cfafcd270661a2f
Reviewed-by: David Chase <drc...@google.com>
Files:
  • M src/cmd/link/internal/x86/asm.go
Change size: XS
Delta: 1 file changed, 3 insertions(+), 0 deletions(-)
Branch: refs/heads/master
Submit Requirements:
  • requirement satisfiedCode-Review: +2 by David Chase
  • requirement satisfiedTryBots-Pass: LUCI-TryBot-Result+1 by Go LUCI
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Iab11106ce592dc5219b7a0e07cfafcd270661a2f
Gerrit-Change-Number: 730161
Gerrit-PatchSet: 6
Gerrit-Owner: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: David Chase <drc...@google.com>
Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages