Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to support 'Windows ARM/ARM64' #28

Merged
merged 3 commits into from
Apr 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions coff/coff.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ type RelocationEntry struct {
const (
_IMAGE_REL_AMD64_ADDR32NB = 0x03
_IMAGE_REL_I386_DIR32NB = 0x07
_IMAGE_REL_ARM64_ADDR32NB = 0x02
_IMAGE_REL_ARM_ADDR32NB = 0x02
)

type Auxiliary [18]byte
Expand Down Expand Up @@ -161,6 +163,13 @@ func (coff *Coff) Arch(arch string) error {
// https://github.com/yasm/yasm/blob/7160679eee91323db98b0974596c7221eeff772c/modules/objfmts/coff/coff-objfmt.c#L38
// FIXME: currently experimental -- not sure if something more doesn't need to be changed
coff.Machine = pe.IMAGE_FILE_MACHINE_AMD64
case "arm":
fcharlie marked this conversation as resolved.
Show resolved Hide resolved
// see
// https://github.com/golang/go/blob/f3424ceff2fa48615ed98580f337ab044925c940/src/cmd/link/internal/ld/pe.go#L736
coff.Machine = pe.IMAGE_FILE_MACHINE_ARMNT
case "arm64":
// Waiting https://github.com/golang/go/issues/36439
coff.Machine = pe.IMAGE_FILE_MACHINE_ARM64
default:
return errors.New("coff: unknown architecture: " + arch)
}
Expand Down Expand Up @@ -253,6 +262,10 @@ func (coff *Coff) AddResource(kind uint32, id uint16, data Sizer) {
re.Type = _IMAGE_REL_I386_DIR32NB
case pe.IMAGE_FILE_MACHINE_AMD64:
re.Type = _IMAGE_REL_AMD64_ADDR32NB
case pe.IMAGE_FILE_MACHINE_ARMNT:
re.Type = _IMAGE_REL_ARM_ADDR32NB
case pe.IMAGE_FILE_MACHINE_ARM64:
re.Type = _IMAGE_REL_ARM64_ADDR32NB
}
coff.Relocations = append(coff.Relocations, re)
coff.SectionHeader32.NumberOfRelocations++
Expand Down
6 changes: 3 additions & 3 deletions rsrc.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"regexp"
"strings"

"github.com/akavel/rsrc/coff"
"github.com/akavel/rsrc/binutil"
"github.com/akavel/rsrc/coff"
"github.com/akavel/rsrc/internal"
"github.com/akavel/rsrc/rsrc"
)
Expand All @@ -36,7 +36,7 @@ func main() {
flags.StringVar(&fnameico, "ico", "", "comma-separated list of paths to .ico files to embed")
flags.StringVar(&fnamedata, "data", "", "path to raw data file to embed [WARNING: useless for Go 1.4+]")
flags.StringVar(&fnameout, "o", "rsrc.syso", "name of output COFF (.res or .syso) file")
flags.StringVar(&arch, "arch", "386", "architecture of output file - one of: 386, [EXPERIMENTAL: amd64]")
flags.StringVar(&arch, "arch", "386", "architecture of output file - one of: 386, amd64, [EXPERIMENTAL: arm, arm64]")
_ = flags.Parse(os.Args[1:])
if fnameout == "" || (fnamein == "" && fnamedata == "" && fnameico == "") {
fmt.Fprintf(os.Stderr, usage, os.Args[0])
Expand Down Expand Up @@ -101,4 +101,4 @@ void ·get_NAME(Slice a) {
}`, "NAME", symname, -1))

return nil
}
}