@@ -7,45 +7,45 @@ import (
77const debugLoader = false
88
99const (
10- R_AARCH64_RELATIVE = 1027
11- DT_NULL = 0 /* Terminating entry. */
12- DT_RELA = 7 /* Address of ElfNN_Rela relocations. */
13- DT_RELASZ = 8 /* Total size of ElfNN_Rela relocations. */
10+ rAARCH64_RELATIVE = 1027
11+ dtNULL = 0 /* Terminating entry. */
12+ dtRELA = 7 /* Address of ElfNN_Rela relocations. */
13+ dtRELASZ = 8 /* Total size of ElfNN_Rela relocations. */
1414)
1515
1616/* ELF64 relocations that need an addend field. */
17- type Rela64 struct {
17+ type rela64 struct {
1818 Off uint64 /* Location to be relocated. */
1919 Info uint64 /* Relocation type and symbol index. */
2020 Addend int64 /* Addend. */
2121}
2222
2323// ELF64 Dynamic structure. The ".dynamic" section contains an array of them.
24- type Dyn64 struct {
24+ type dyn64 struct {
2525 Tag int64 /* Entry type. */
2626 Val uint64 /* Integer/address value */
2727}
2828
2929//export __dynamic_loader
30- func dynamicLoader (base uintptr , dyn * Dyn64 ) {
31- var rela * Rela64
30+ func dynamicLoader (base uintptr , dyn * dyn64 ) {
31+ var rela * rela64
3232 relasz := uint64 (0 )
3333
3434 if debugLoader {
3535 println ("ASLR Base: " , base )
3636 }
3737
38- for dyn .Tag != DT_NULL {
38+ for dyn .Tag != dtNULL {
3939 switch dyn .Tag {
40- case DT_RELA :
41- rela = (* Rela64 )(unsafe .Pointer (base + uintptr (dyn .Val )))
42- case DT_RELASZ :
43- relasz = uint64 (dyn .Val ) / uint64 (unsafe .Sizeof (Rela64 {}))
40+ case dtRELA :
41+ rela = (* rela64 )(unsafe .Pointer (base + uintptr (dyn .Val )))
42+ case dtRELASZ :
43+ relasz = uint64 (dyn .Val ) / uint64 (unsafe .Sizeof (rela64 {}))
4444 }
4545
4646 ptr := uintptr (unsafe .Pointer (dyn ))
47- ptr += unsafe .Sizeof (Dyn64 {})
48- dyn = (* Dyn64 )(unsafe .Pointer (ptr ))
47+ ptr += unsafe .Sizeof (dyn64 {})
48+ dyn = (* dyn64 )(unsafe .Pointer (ptr ))
4949 }
5050
5151 if rela == nil {
@@ -58,14 +58,14 @@ func dynamicLoader(base uintptr, dyn *Dyn64) {
5858
5959 for relasz > 0 && rela != nil {
6060 switch rela .Info {
61- case R_AARCH64_RELATIVE :
61+ case rAARCH64_RELATIVE :
6262 ptr := (* uint64 )(unsafe .Pointer (base + uintptr (rela .Off )))
6363 * ptr = uint64 (base + uintptr (rela .Addend ))
6464 }
6565
6666 rptr := uintptr (unsafe .Pointer (rela ))
67- rptr += unsafe .Sizeof (Rela64 {})
68- rela = (* Rela64 )(unsafe .Pointer (rptr ))
67+ rptr += unsafe .Sizeof (rela64 {})
68+ rela = (* rela64 )(unsafe .Pointer (rptr ))
6969 relasz --
7070 }
7171}
0 commit comments