Skip to content

Commit

Permalink
debug/elf,cmd/link: add additional MIPS64 relocation type
Browse files Browse the repository at this point in the history
Add R_MIPS_PC32 which is a 32 bit PC relative relocation.

These are produced by LLVM on mips64.

Fixes #61974

Change-Id: I7b6c6848e40249e6d5ea474ea53c9d7e3ab23f88
Reviewed-on: https://go-review.googlesource.com/c/go/+/469395
Reviewed-by: Matthew Dempsky <[email protected]>
Run-TryBot: Joel Sing <[email protected]>
Reviewed-by: Junxian Zhu <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
  • Loading branch information
4a6f656c authored and pull[bot] committed Mar 26, 2024
1 parent 020169e commit 1754450
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api/next/61974.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pkg debug/elf, const R_MIPS_PC32 = 248 #61974
pkg debug/elf, const R_MIPS_PC32 R_MIPS #61974
3 changes: 2 additions & 1 deletion src/cmd/link/internal/loadelf/ldelf.go
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,8 @@ func relSize(arch *sys.Arch, pn string, elftype uint32) (uint8, uint8, error) {
MIPS64 | uint32(elf.R_MIPS_CALL16)<<16,
MIPS64 | uint32(elf.R_MIPS_GPREL32)<<16,
MIPS64 | uint32(elf.R_MIPS_64)<<16,
MIPS64 | uint32(elf.R_MIPS_GOT_DISP)<<16:
MIPS64 | uint32(elf.R_MIPS_GOT_DISP)<<16,
MIPS64 | uint32(elf.R_MIPS_PC32)<<16:
return 4, 4, nil

case LOONG64 | uint32(elf.R_LARCH_SOP_PUSH_PCREL)<<16,
Expand Down
3 changes: 3 additions & 0 deletions src/debug/elf/elf.go
Original file line number Diff line number Diff line change
Expand Up @@ -2216,6 +2216,8 @@ const (
R_MIPS_TLS_TPREL64 R_MIPS = 48 /* TP-relative offset, 64 bit */
R_MIPS_TLS_TPREL_HI16 R_MIPS = 49 /* TP-relative offset, high 16 bits */
R_MIPS_TLS_TPREL_LO16 R_MIPS = 50 /* TP-relative offset, low 16 bits */

R_MIPS_PC32 R_MIPS = 248 /* 32 bit PC relative reference */
)

var rmipsStrings = []intName{
Expand Down Expand Up @@ -2267,6 +2269,7 @@ var rmipsStrings = []intName{
{48, "R_MIPS_TLS_TPREL64"},
{49, "R_MIPS_TLS_TPREL_HI16"},
{50, "R_MIPS_TLS_TPREL_LO16"},
{248, "R_MIPS_PC32"},
}

func (i R_MIPS) String() string { return stringName(uint32(i), rmipsStrings, false) }
Expand Down

0 comments on commit 1754450

Please sign in to comment.