Skip to content

Commit

Permalink
chore: small refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Jul 3, 2020
1 parent eb0a424 commit 81b477e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
5 changes: 1 addition & 4 deletions cmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -841,8 +841,7 @@ func (f *FunctionStarts) String() string {
return fmt.Sprintf("offset=0x%08x-0x%08x, size=%5d, count=%d", f.Offset, f.Offset+f.Size, f.Size, len(f.VMAddrs))
}

// TODO: LC_DYLD_ENVIRONMENT 0x27 /* string for dyld to treat
// like environment variable */
// TODO: LC_DYLD_ENVIRONMENT 0x27 /* string for dyld to treat like environment variable */

/*******************************************************************************
* LC_MAIN
Expand Down Expand Up @@ -1035,8 +1034,6 @@ func (cf *DyldChainedFixups) String() string {
return fmt.Sprintf("Offset: 0x%x, Size: 0x%x, Imports: %d", cf.Offset, cf.Size, cf.ImportsCount)
}

// TODO: LC_FILESET_ENTRY LoadCmd = (0x35 | LC_REQ_DYLD) /* used with fileset_entry_command */

/*******************************************************************************
* LC_FILESET_ENTRY
*******************************************************************************/
Expand Down
10 changes: 5 additions & 5 deletions types/dyld_chained_fixups.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ const (
type DyldChainedPtrArm64eRebase uint64

func (d DyldChainedPtrArm64eRebase) Target() uint64 {
return fse_extract_bits(uint64(d), 0, 43)
return ExtractBits(uint64(d), 0, 43)
}
func (d DyldChainedPtrArm64eRebase) High8() uint64 {
return fse_extract_bits(uint64(d), 43, 8)
return ExtractBits(uint64(d), 43, 8)
}
func (d DyldChainedPtrArm64eRebase) Next() uint64 {
return fse_extract_bits(uint64(d), 51, 11)
return ExtractBits(uint64(d), 51, 11)
}
func (d DyldChainedPtrArm64eRebase) Bind() uint64 {
return fse_extract_bits(uint64(d), 62, 1)
return ExtractBits(uint64(d), 62, 1)
}
func (d DyldChainedPtrArm64eRebase) Auth() uint64 {
return fse_extract_bits(uint64(d), 63, 1)
return ExtractBits(uint64(d), 63, 1)
}

// DYLD_CHAINED_PTR_ARM64E
Expand Down
6 changes: 3 additions & 3 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ var lsb64Mtable = [65]uint64{
0x7fffffffffffffff, 0xffffffffffffffff,
}

func fse_mask_lsb64(x uint64, nbits uint8) uint64 {
func MaskLSB64(x uint64, nbits uint8) uint64 {
return x & lsb64Mtable[nbits]
}

func fse_extract_bits(x uint64, start, nbits int32) uint64 {
return fse_mask_lsb64(x>>start, uint8(nbits))
func ExtractBits(x uint64, start, nbits int32) uint64 {
return MaskLSB64(x>>start, uint8(nbits))
}

0 comments on commit 81b477e

Please sign in to comment.