mirror of
https://github.com/golang/go.git
synced 2025-05-17 13:24:38 +00:00
cmd/link: recognize arm header of PE objects
The linker recognizes headers for 386 and amd64 PE objects, but not arm objects. This is easily overlooked, since its the same as the 386 header value, except the two nibbles of the first word are swapped. This commit simply adds the check for this. Without it, .syso objects are rejected, which means Windows binaries can't have resources built into them. At the same time, we add comments to better indicate which condition applies to which arch. Change-Id: I210411d978504c1a9540e23abc5a180e24f159ad Reviewed-on: https://go-review.googlesource.com/c/go/+/268237 Reviewed-by: Cherry Zhang <cherryyz@google.com> Trust: Alex Brainman <alex.brainman@gmail.com> Trust: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
48906a6d57
commit
033390d9ad
@ -1801,7 +1801,7 @@ func ldobj(ctxt *Link, f *bio.Reader, lib *sym.Library, length int64, pn string,
|
|||||||
return ldhostobj(ldmacho, ctxt.HeadType, f, pkg, length, pn, file)
|
return ldhostobj(ldmacho, ctxt.HeadType, f, pkg, length, pn, file)
|
||||||
}
|
}
|
||||||
|
|
||||||
if c1 == 0x4c && c2 == 0x01 || c1 == 0x64 && c2 == 0x86 {
|
if /* x86 */ c1 == 0x4c && c2 == 0x01 || /* x86_64 */ c1 == 0x64 && c2 == 0x86 || /* armv7 */ c1 == 0xc4 && c2 == 0x01 {
|
||||||
ldpe := func(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
|
ldpe := func(ctxt *Link, f *bio.Reader, pkg string, length int64, pn string) {
|
||||||
textp, rsrc, err := loadpe.Load(ctxt.loader, ctxt.Arch, ctxt.IncVersion(), f, pkg, length, pn)
|
textp, rsrc, err := loadpe.Load(ctxt.loader, ctxt.Arch, ctxt.IncVersion(), f, pkg, length, pn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user