-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix #92, function in text segment align with funcalign
- Loading branch information
Showing
4 changed files
with
89 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//go:build go1.15 && !go1.16 | ||
// +build go1.15,!go1.16 | ||
|
||
package funcalign | ||
|
||
import ( | ||
"cmd/objfile/sys" | ||
"fmt" | ||
) | ||
|
||
func GetFuncAlign(arch *sys.Arch) int { | ||
switch arch.Name { | ||
//see:^cmd/linker/internal/arm/l.go | ||
case sys.ArchARM.Name: | ||
return 4 | ||
//see:^cmd/linker/internal/arm64/l.go | ||
case sys.ArchARM64.Name: | ||
return 16 | ||
//see:^cmd/linker/internal/x86/l.go | ||
case sys.Arch386.Name: | ||
return 16 | ||
// see:^cmd/linker/internal/amd64/l.go | ||
case sys.ArchAMD64.Name: | ||
return 16 | ||
default: | ||
panic(fmt.Errorf("not support arch:%s", arch.Name)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//go:build go1.16 && !go1.22 | ||
// +build go1.16,!go1.22 | ||
|
||
package funcalign | ||
|
||
import ( | ||
"cmd/objfile/sys" | ||
"fmt" | ||
) | ||
|
||
func GetFuncAlign(arch *sys.Arch) int { | ||
switch arch.Name { | ||
//see:^cmd/linker/internal/arm/l.go | ||
case sys.ArchARM.Name: | ||
return 4 | ||
//see:^cmd/linker/internal/arm64/l.go | ||
case sys.ArchARM64.Name: | ||
return 16 | ||
//see:^cmd/linker/internal/x86/l.go | ||
case sys.Arch386.Name: | ||
return 16 | ||
// see:^cmd/linker/internal/amd64/l.go | ||
case sys.ArchAMD64.Name: | ||
return 32 | ||
default: | ||
panic(fmt.Errorf("not support arch:%s", arch.Name)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//go:build go1.8 && !go1.15 | ||
// +build go1.8,!go1.15 | ||
|
||
package funcalign | ||
|
||
import ( | ||
"cmd/objfile/sys" | ||
"fmt" | ||
) | ||
|
||
func GetFuncAlign(arch *sys.Arch) int { | ||
switch arch.Name { | ||
//see:^cmd/linker/internal/arm/l.go | ||
case sys.ArchARM.Name: | ||
return 4 | ||
//see:^cmd/linker/internal/arm64/l.go | ||
case sys.ArchARM64.Name: | ||
return 8 | ||
//see:^cmd/linker/internal/x86/l.go | ||
case sys.Arch386.Name: | ||
return 16 | ||
// see:^cmd/linker/internal/amd64/l.go | ||
case sys.ArchAMD64.Name: | ||
return 16 | ||
default: | ||
panic(fmt.Errorf("not support arch:%s", arch.Name)) | ||
} | ||
} |