187 Commits

Author SHA1 Message Date
ahhh 247eb13f12 clone works, although an offset is not quite right, feels like 4 bytes off somewhere. cloned binaries still run 2019-02-20 23:26:37 -08:00
ahhh 37e08f3b00 Got fat header cloned, time to add fat files at proper offsets 2019-02-20 20:52:00 -08:00
ahhh c245e95876 Adding some of the fat / universalmacho cloning functionality 2019-02-20 20:10:20 -08:00
Dan Borges b89922c4e3 Merge pull request #6 from Binject/macho_write
refactoring macho's write.go
2019-02-04 07:38:35 -08:00
dborges 40b8d11c14 refactoring macho's write.go to use WriteFile and Bytes, such that the files can be constructed without being written to disk 2019-02-03 18:22:15 -08:00
Dan Borges 900b9af30e Merge pull request #5 from Binject/macho-cleanup
cleaning up comments a bit
2019-01-30 22:52:43 -08:00
ahhh ee21b37c19 update to macho write 2019-01-30 19:54:40 -08:00
awgh c914c9d515 Added Virtual Memory Segment Protection flag constants for Mach-O. 2019-01-29 23:52:49 -08:00
ahhh daa4766242 cleaning up comments a bit 2019-01-29 19:38:44 -08:00
Andrew LeFevre 2f826f277d Small optimization to only write PE cert info if it changed 2019-01-28 18:05:24 -05:00
Andrew LeFevre ac54a07fc1 Separate PE writing logic into two functions, fix cert writing (again) 2019-01-28 17:15:04 -05:00
Andrew LeFevre 564c67b7e0 More refactoring/fixing 2019-01-28 15:53:11 -05:00
Andrew LeFevre b8a29f67bf Refactored and improved cert writing code 2019-01-28 14:47:04 -05:00
Andrew LeFevre a9b465661b Small tweak to correctly write certain files that don't have a Rich header 2019-01-28 13:55:48 -05:00
Andrew LeFevre 8fcbc6782c Added comments 2019-01-27 23:41:40 -05:00
Andrew LeFevre e3d3d8509f PE parsing and writing Rich header working 2019-01-27 23:36:30 -05:00
Dan Borges 247614b64c Merge pull request #4 from Binject/moreloadcmds
Like a boss
2019-01-27 15:04:17 -08:00
ahhh 4dc14f1dad Finished parsing the Dynlinker Info blocks and associated data structures. Can properly parse and write signed apple macho binaries now 2019-01-27 15:03:06 -08:00
ahhh cbf3116125 more parsing 2019-01-27 00:44:55 -08:00
ahhh 50e8551ad8 properly parses and writes the 'Function Starts' and 'Data in Code Entrie' blocks now 2019-01-27 00:17:27 -08:00
ahhh af93ba4ec8 updating parsed structures 2019-01-26 23:53:06 -08:00
ahhh 6b99be8ca5 defining more macho load commands 2019-01-26 23:25:31 -08:00
Dan Borges 322fabcdd3 Merge pull request #3 from Binject/macho_sig
Macho sig
2019-01-25 00:13:30 -08:00
ahhh 38bfa0a76e more work on parsing / writing signature block 2019-01-24 23:44:14 -08:00
ahhh dcafd9279a Adding some basic parsing of the signature block data for macho files 2019-01-24 22:42:08 -08:00
awgh 1af8ff55cc Removed buggy alignment code from debug/macho Write. It now clones (unsigned) machos perfectly! 2019-01-24 00:10:50 -08:00
awgh eca0043cb0 Merge pull request #2 from Binject/breaking_newz
Breaking newz
2019-01-21 13:27:21 -08:00
ahhh 1a45d0ded9 notes + direction 2019-01-21 02:19:09 -08:00
ahhh a9082f21ec Parsing file length properly now, means things like otool work, although files still dont run 2019-01-21 02:05:32 -08:00
ahhh 23659355cb more of the macho file done 2019-01-21 01:52:53 -08:00
ahhh ab441c8924 I think symbols come next in the binaries, but having trouble writing them 2019-01-18 17:28:27 -08:00
Andrew LeFevre ad93c6b189 pe.Write now working with certs 2019-01-17 23:06:18 -05:00
Andrew LeFevre 85680fcd79 pe.Write mostly complete, produces files that execute but with different hashes... 2019-01-17 21:59:53 -05:00
Andrew LeFevre 6bb96c4eba File header writing working for PEs 2019-01-17 19:22:38 -05:00
Andrew LeFevre 66129e3cc8 Added parsing of Dos Header and Stub to debug/pe, cleaned up NewFile 2019-01-17 19:21:01 -05:00
Dan Borges 44dc575a7b Merge pull request #1 from Binject/macho-dev
Adding a write function to write macho bins
2019-01-16 20:56:45 -08:00
Dan Borges d0bba96460 Adding a write function to write macho bins 2019-01-16 20:50:39 -08:00
awgh dac374cdaa Added the ability to insert additional bytes at the end of a section and removed a debug print statement. 2019-01-15 02:19:09 -08:00
awgh f9c5d4cc10 Initial check-in of Elf format Write() method, which write a file to disk from an elf.File. 2019-01-14 22:19:02 -08:00
awgh 9fb31bd0d1 Added the Shared Header Table offset and Shared String Table Index vars to the File header and NewFile.
These are needed fields to rebuild a working Elf from an elf.File.
2019-01-14 19:07:00 -08:00
LE Manh Cuong 4fb3b4b067 debug/gosym: remove outdated comment
Change-Id: I2bba13064c8d21ded41499c6ec225ef83d1a533e
Reviewed-on: https://go-review.googlesource.com/c/156997
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-01-09 14:44:28 +00:00
Tobias Klauser 44fa21c17b all: use "reports whether" consistently instead of "returns whether"
Follow-up for CL 147037 and after Brad noticed the "returns whether"
pattern during the review of CL 150621.

Go documentation style for boolean funcs is to say:

    // Foo reports whether ...
    func Foo() bool

(rather than "returns whether")

Created with:

    $ perl -i -npe 's/returns whether/reports whether/' $(git grep -l "returns whether" | grep -v vendor)

Change-Id: I15fe9ff99180ad97750cd05a10eceafdb12dc0b4
Reviewed-on: https://go-review.googlesource.com/c/150918
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-12-02 15:12:26 +00:00
Alex Brainman 497d114ce9 debug/pe: use ws2_32.dll in TestImportTableInUnknownSection
Apparently (see
https://github.com/golang/go/issues/27904#issuecomment-442140627
for details) kernel32.dll file is not present on windows/arm, so
use ws2_32.dll instead. ws2_32.dll imports table also lives in
'.rdata' section, so ws2_32.dll is as good as kernel32.dll for
testing issue #16103.

Updates #27904

Change-Id: Ibc72b24eea9a4d85abd371ffdcf00442e711b745
Reviewed-on: https://go-review.googlesource.com/c/151480
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-29 08:30:13 +00:00
Alex Brainman e7eabeb4ba debug/pe: correct TestImportTableInUnknownSection error message
TestImportTableInUnknownSection uses kernel32.dll file, but the error
message mentions atmfd.dll. Adjust error message to match the test.

This change should have been part of CL 151137.

Updates #27904

Change-Id: Ifc31a12134b328472191122f8426ab6ed234fbd4
Reviewed-on: https://go-review.googlesource.com/c/151477
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2018-11-27 09:26:16 +00:00
Alex Brainman 0d87393ea3 debug/pe: use kernel32.dll in TestImportTableInUnknownSection
TestImportTableInUnknownSection was introduced in CL 110555 to
test PE executable with import table located in section other than
".idata". We used atmfd.dll for that purpose, but it seems
atmfd.dll is not present on some systems.

Use kernel32.dll instead. kernel32.dll import table is located in
".rdata" section, so it should do the job. And every Windows
system has kernel32.dll file.

Also make TestImportTableInUnknownSection run on windows-arm,
since windows-arm should also have kernel32.dll file.

Updates #27904

Change-Id: Ie005ee10e46ae0c06e83929d581e89f86c051eea
Reviewed-on: https://go-review.googlesource.com/c/151137
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-24 23:55:07 +00:00
Austin Clements c1e9d59d56 debug/gosym: use "go build" instead of hand-running asm and link
Currently, TestPCLine manually invokes asm and link on its test data.
Once we introduce symbol ABIs this is going to become problematic
because the test program defines main.main and main.init in assembly
so they use ABI0, but the runtime expects to find them with the
internal ABI.

There are various ways we could solve this. This CL moves main.main
and main.init into Go code and switches to using "go build" to compile
and link the test binary. This has the added advantage of simplifying
this test.

For #27539.

Change-Id: I4c0cf6467f7a39e6b1500eca6ad2620b5ef2b73c
Reviewed-on: https://go-review.googlesource.com/c/146857
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-12 20:27:20 +00:00
Clément Chigot 459c209f8a all: skip unsupported tests on AIX
This commit skips tests which aren't yet supported on AIX.

nosplit.go is disabled because stackGuardMultiplier is increased for
syscalls.

Change-Id: Ib5ff9a4539c7646bcb6caee159f105ff8a160ad7
Reviewed-on: https://go-review.googlesource.com/c/146939
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-02 16:12:08 +00:00
OlgaVlPetrova b37ab1976e debug/plan9obj: simplify s[:] to s where
Change-Id: Ib2eee1215ba046e4541af8afa3a921c680d2b37e
Reviewed-on: https://go-review.googlesource.com/c/142037
Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Iskander Sharipov <iskander.sharipov@intel.com>
2018-10-13 11:24:43 +00:00
Jordan Rhee 14138f7f43 debug/pe: fix TestDWARF to work with relocations
Fixes #27904

Change-Id: Ie2aad20cd66785b6cc1018c0048824382cb39f8c
Reviewed-on: https://go-review.googlesource.com/c/140158
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-05 20:30:11 +00:00
Brad Fitzpatrick ce3af89ba5 debug/pe: skip a test on windows/arm
It requires a DLL that's not available on windows/arm apparently.

Fixes #27904

Change-Id: I082a273f62976b7184636c6aeca6201a7871d238
Reviewed-on: https://go-review.googlesource.com/c/139720
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-10-04 17:50:01 +00:00