Skip to content

Commit

Permalink
add reloc type R_KEEP
Browse files Browse the repository at this point in the history
  • Loading branch information
pkujhd committed Feb 17, 2024
1 parent 3b6cea6 commit 7ea435d
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 2 deletions.
3 changes: 3 additions & 0 deletions objabi/reloctype/reloctype.1.16.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ const (
// *rtype, and may be set to zero by the linker if it determines the method
// text is unreachable by the linked program.
R_METHODOFF = (int)(objabi.R_METHODOFF)
// R_KEEP tells the linker to keep the referred-to symbol in the final binary
// if the symbol containing the R_KEEP relocation is in the final binary.
R_KEEP = (int)(objabi.R_KEEP)

Check failure on line 57 in objabi/reloctype/reloctype.1.16.go

View workflow job for this annotation

GitHub Actions / build (16, ubuntu-latest)

undefined: objabi.R_KEEP

Check failure on line 57 in objabi/reloctype/reloctype.1.16.go

View workflow job for this annotation

GitHub Actions / build (16, windows-latest)

undefined: objabi.R_KEEP

Check failure on line 57 in objabi/reloctype/reloctype.1.16.go

View workflow job for this annotation

GitHub Actions / build (16, macos-latest)

undefined: objabi.R_KEEP
// R_ADDRCUOFF resolves to a pointer-sized offset from the start of the
// symbol's DWARF compile unit.
R_ADDRCUOFF = (int)(objabi.R_ADDRCUOFF)
Expand Down
4 changes: 4 additions & 0 deletions objabi/reloctype/reloctype.1.17.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ const (
// *rtype, and may be set to zero by the linker if it determines the method
// text is unreachable by the linked program.
R_METHODOFF = (int)(objabi.R_METHODOFF)
// R_KEEP tells the linker to keep the referred-to symbol in the final binary
// if the symbol containing the R_KEEP relocation is in the final binary.
R_KEEP = (int)(objabi.R_KEEP)

R_GOTPCREL = (int)(objabi.R_GOTPCREL)

Expand All @@ -70,6 +73,7 @@ const (

const (
//not used, only adapter golang higher version

R_INITORDER = 0x10000000 - 9
R_ARM64_PCREL_LDST8 = 0x10000000 - 8
R_ARM64_PCREL_LDST16 = 0x10000000 - 7
Expand Down
4 changes: 3 additions & 1 deletion objabi/reloctype/reloctype.1.20.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ const (
// *rtype, and may be set to zero by the linker if it determines the method
// text is unreachable by the linked program.
R_METHODOFF = (int)(objabi.R_METHODOFF)

// R_KEEP tells the linker to keep the referred-to symbol in the final binary
// if the symbol containing the R_KEEP relocation is in the final binary.
R_KEEP = (int)(objabi.R_KEEP)
// R_ADDRCUOFF resolves to a pointer-sized offset from the start of the
// symbol's DWARF compile unit.
R_ADDRCUOFF = (int)(objabi.R_ADDRCUOFF)
Expand Down
3 changes: 3 additions & 0 deletions objabi/reloctype/reloctype.1.21.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ const (
// *rtype, and may be set to zero by the linker if it determines the method
// text is unreachable by the linked program.
R_METHODOFF = (int)(objabi.R_METHODOFF)
// R_KEEP tells the linker to keep the referred-to symbol in the final binary
// if the symbol containing the R_KEEP relocation is in the final binary.
R_KEEP = (int)(objabi.R_KEEP)

// R_ADDRCUOFF resolves to a pointer-sized offset from the start of the
// symbol's DWARF compile unit.
Expand Down
1 change: 1 addition & 0 deletions objabi/reloctype/reloctype.1.8.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const (

const (
//not used, only adapter golang higher version
R_KEEP = 0x10000000 - 10
R_INITORDER = 0x10000000 - 9
R_ARM64_PCREL_LDST8 = 0x10000000 - 8
R_ARM64_PCREL_LDST16 = 0x10000000 - 7
Expand Down
1 change: 1 addition & 0 deletions objabi/reloctype/reloctype.1.9.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const (

const (
//not used, only adapter golang higher version
R_KEEP = 0x10000000 - 10
R_INITORDER = 0x10000000 - 9
R_ARM64_PCREL_LDST8 = 0x10000000 - 8
R_ARM64_PCREL_LDST16 = 0x10000000 - 7
Expand Down
2 changes: 1 addition & 1 deletion register.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func typelinksRegister(symPtr map[string]uintptr) {
if int(f.funcoff) < len(md.pclntable) {
_func := (*_func)(unsafe.Pointer(&(md.pclntable[f.funcoff])))
name := getfuncname(_func, &md)
if !strings.HasPrefix(name, constants.TypeDoubleDotPrefix) && name != EmptyString {
if name != EmptyString {
if _, ok := symPtr[name]; !ok {
symPtr[name] = getfuncentry(_func, md.text)
}
Expand Down
2 changes: 2 additions & 0 deletions relocate.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ func (linker *Linker) relocate(codeModule *CodeModule, symbolMap, symPtr map[str
reloctype.R_ADDRCUOFF,
reloctype.R_INITORDER:
//nothing todo
case reloctype.R_KEEP:
//nothing todo
default:
err = fmt.Errorf("unknown reloc type:%s sym:%s", reloctype.RelocTypeString(loc.Type), loc.SymName)
}
Expand Down

0 comments on commit 7ea435d

Please sign in to comment.