aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/ld/pe.c
AgeCommit message (Collapse)Author
2015-03-01cmd/5l etc: replace C code with Go codeRuss Cox
mv cmd/new5l cmd/5l and so on. Minimal changes to cmd/dist and cmd/go to keep things building. More can be deleted in followup CLs. Change-Id: I1449eca7654ce2580d1f413a56dc4a75f3d4618b Reviewed-on: https://go-review.googlesource.com/6361 Reviewed-by: Rob Pike <r@golang.org>
2015-03-01cmd/ld: clean for c2goRuss Cox
Change-Id: Iaab2be9a1919f2fa9dbc61a5b7fbf99bcd0712a9 Reviewed-on: https://go-review.googlesource.com/6332 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Minux Ma <minux@golang.org>
2015-02-13cmd/ld: make cmd/ld a real libraryRuss Cox
Make cmd/ld a real library invoked by the individual linkers. There are no reverse symbol references anymore (symbols referred to in cmd/ld but defined in cmd/5l etc). This means that in principle we could do an automatic conversion of these to Go, as a stopgap until cmd/link is done or as a replacement for cmd/link. Change-Id: I4a94570257a3a7acc31601bfe0fad9dea0aea054 Reviewed-on: https://go-review.googlesource.com/4649 Reviewed-by: Rob Pike <r@golang.org>
2015-02-05cmd/ld: always set timestamp in PE header to 0Shenghou Ma
Fixes #9756. Change-Id: If4ee6fe10f8f90294ff9c5e7480371494094b111 Signed-off-by: Shenghou Ma <minux@golang.org> Reviewed-on: https://go-review.googlesource.com/3740 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2014-05-06cmd/ld: correct pe section number in symbol tableAlex Brainman
Update #7899 LGTM=iant R=golang-codereviews, rsc, iant CC=golang-codereviews https://golang.org/cl/97920044
2014-04-21cmd/ld: correct addresses in windows pe symbol tableAlex Brainman
This should have been part of 36eb4a62fbb6, but I later discovered that addresses are all wrong. Appropriate test added now. LGTM=r R=golang-codereviews, r CC=golang-codereviews https://golang.org/cl/89470043
2014-04-16cmd/ld: populate pe symbol table with Go symbolsAlex Brainman
Fixes #6936 LGTM=rsc R=golang-codereviews, bradfitz, rsc CC=golang-codereviews https://golang.org/cl/87770048
2014-03-26runtime: use VEH for windows/amd64 exception handlingAlex Brainman
Fixes windows/amd64 build. LGTM=rsc R=golang-codereviews, rsc CC=golang-codereviews https://golang.org/cl/79470046
2013-12-08liblink: create new library based on linker codeRuss Cox
There is an enormous amount of code moving around in this CL, but the code is the same, and it is invoked in the same ways. This CL is preparation for the new linker structure, not the new structure itself. The new library's definition is in include/link.h. The main change is the use of a Link structure to hold all the linker-relevant state, replacing the smattering of global variables. The Link structure should both make it clearer which state must be carried around and make it possible to parallelize more easily later. The main body of the linker has moved into the architecture-independent cmd/ld directory. That includes the list of known header types, so the distinction between Hplan9x32 and Hplan9x64 is removed (no other header type distinguished 32- and 64-bit formats), and code for unused formats such as ipaq kernels has been deleted. The code being deleted from 5l, 6l, and 8l reappears in liblink or in ld. Because multiple files are being merged in the liblink directory, it is not possible to show the diffs nicely in hg. The Prog and Addr structures have been unified into an architecture-independent form and moved to link.h, where they will be shared by all tools: the assemblers, the compilers, and the linkers. The unification makes it possible to write architecture-independent traversal of Prog lists, among other benefits. The Sym structures cannot be unified: they are too fundamentally different between the linker and the compilers. Instead, liblink defines an LSym - a linker Sym - to be used in the Prog and Addr structures, and the linker now refers exclusively to LSyms. The compilers will keep using their own syms but will fill out the corresponding LSyms in the Prog and Addr structures. Although code from 5l, 6l, and 8l is now in a single library, the code has been arranged so that only one architecture needs to be linked into a particular program: 5l will not contain the code needed for x86 instruction layout, for example. The object file writing code in liblink/obj.c is from cmd/gc/obj.c. Preparation for golang.org/s/go13linker work. This CL does not build by itself. It depends on 35740044 and will be submitted at the same time. R=iant CC=golang-dev https://golang.org/cl/35790044
2013-09-23cmd/ld: fix "_image_base__ not defined" problem for cmd/8l.Shenghou Ma
Fixes #6431. Change suggested by kin.wilson.za. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/13314048
2013-03-10cmd/ld: replace dynimpname with extnameRuss Cox
Dynimpname was getting too confusing. Replace flag-like checks with tests of s->type. R=ken2 CC=golang-dev https://golang.org/cl/7594046
2013-03-07cmd/ld: host linking support for linux/amd64Russ Cox
Still to do: non-linux and non-amd64. It may work on other ELF-based amd64 systems too, but untested. "go test -ldflags -hostobj $GOROOT/misc/cgo/test" passes. Much may yet change, but this seems a reasonable checkpoint. R=iant CC=golang-dev https://golang.org/cl/7369057
2013-01-04cmd/5g, cmd/5l, cmd/ld: Small adjustments for the Plan 9 native toolsLucio De Re
A few USED(xxx) additions and a couple of deletions of variable initialisations that go unused. One questionable correction, mirrored in 8l/asm.c, where the result of invocation of a function shouldn't be used. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/6736054
2012-11-18runtime/cgo: fix compilation on Windows with CFLAGS -Wall -WerrorShenghou Ma
also fix one out-of-date comment in cmd/ld/pe.c as well. R=golang-dev, alex.brainman CC=golang-dev https://golang.org/cl/6843061
2012-09-26cmd/go, cmd/ld: fix libgcc order and add __image_base__ symbol for windowsShenghou Ma
Fixes #4063. R=alex.brainman, rsc CC=golang-dev https://golang.org/cl/6543066
2011-12-07ld: increase default stack size on Windows for cgoDmitriy Vyukov
Fixes #2437. R=rsc, hectorchu, mattn.jp, alex.brainman, jdpoirier, snaury, n13m3y3r CC=golang-dev https://golang.org/cl/5371049
2011-10-18ld: bump pe linker version to 3.0 to allow code signingMikkel Krautz
The Windows signtool.exe thinks our binaries are 'invalid Win32 programs' unless the PE linker version field is 3.0 or greater. This minor change makes it possible to successfully sign gc-built binaries on Windows. R=golang-dev, alex.brainman, rsc CC=golang-dev https://golang.org/cl/5268045
2011-09-03runtime: implement exception handling on windows/amd64Hector Chu
Fixes #2194. R=rsc, alex.brainman, vcc.163, jp CC=golang-dev https://golang.org/cl/4977044
2011-08-29libmach: support reading symbols from Windows .exe for nmMateusz Czapliński
Fixes #979. R=rsc, alex.brainman CC=golang-dev, vcc.163 https://golang.org/cl/4894051
2011-08-10ld: add one empty symbol into pe to make dumpbin works.Wei Guangjing
Fixes #2139. R=golang-dev, alex.brainman CC=golang-dev https://golang.org/cl/4838056
2011-08-01cmd/ld/pe.c: Corrected mismatched print formats and variables.Lucio De Re
R=golang-dev, alex.brainman CC=golang-dev, rsc https://golang.org/cl/4839041
2011-07-28ld: remove cseekend and redo pe writingAlex Brainman
Simplify code and add more checks. Fixes #2105. R=rsc CC=golang-dev https://golang.org/cl/4794060
2011-07-20ld: remove overlap of ELF sections on dynamic binariesGustavo Niemeyer
The dynamic ELF sections were pointing to the proper data, but that data was already owned by the rodata and text sections. Some ELF references explicitly prohibit multiple sections from owning the same data, and strip behaves accordingly. The data for these sections was moved out and their ranges are now owned by their respective sections. This change makes strip happy both with and without -s being provided at link time. A test was added in debug/elf to ensure there are no regressions on this area in the future. Fixes #1242. Fixes #2022. NOTE: Tested on Linux amd64/386/arm only. R=rsc CC=golang-dev https://golang.org/cl/4808043
2011-07-18ld: allow seek within write bufferRuss Cox
Reduces number of write+seek's from 88516 to 2080 when linking godoc with 6l. Thanks to Alex Brainman for pointing out the many small writes. R=golang-dev, r, alex.brainman, robert.hencke CC=golang-dev https://golang.org/cl/4743043
2011-06-218l: more fixes for Plan 9Lucio De Re
Once these changes are effected, it is possible to construct "8l" native on a (386?) Plan 9 system, albeit with assistance from modules such as mkfiles that are not (yet) included in any public patches. 8l/asm.c: . Corrected some format qualifiers. 8l/list.c: . Cast a print() argument to (int) to match the given format. It may be possible to change the format (%R), but I have not looked into it. 8l/obj.c: . Removed some unused code. 8l/span.c: . Removed unnecessary incrementation on "bp". . Corrected some format qualifiers. ld/data.c: . Corrected some format qualifiers. . Cast print argument to (int): used as field size. . Use braces to suppress warning about empty if() statements. ld/dwarf.c: . Trivial spelling mistake in comment. ld/ldelf.c: . Added USED() statements to silence warnings. . Dropped redundant address (&) operators. . corrected some format qualifiers. . Cast to (int) for switch selection variable. ld/macho.c: . Added USED() statements to silence warnings. ld/ldpe.c: . Added USED() statements to silence warnings. . More careful use of "sect" variable. . Corrected some format qualifiers. . Removed redundant assignments. . Minor fix dropped as it was submitted separately. ld/pe.c: . Dropped <time.h> which is now in <u.h>. . Dropped redundant address (&) operators. . Added a missing variable initialisation. ld/symtab.c: . Added USED() statements to silence warnings. . Removed redundant incrementation. . Corrected some format qualifiers. All the above have been tested against a (very) recent release and do not seem to trigger any regressions. All review suggestions have been incorporated. R=rsc CC=golang-dev https://golang.org/cl/4633043
2011-05-258l: emit resources (.rsrc) in Windows PE.Wei Guangjing
R=alex.brainman, rsc CC=golang-dev, vcc.163 https://golang.org/cl/4516055
2011-05-136l, 8l: emit windows dwarf sections similar to other platformsAlex Brainman
R=golang-dev, rsc CC=golang-dev, vcc.163 https://golang.org/cl/4517056
2011-04-268l: do not emit empty dwarf pe sectionsAlex Brainman
This change will allow to generate valid executable, even if rsc disables dwarf generation, as it happend at revision 9a64273f9d68. R=rsc CC=golang-dev, lvd, vcc https://golang.org/cl/4425066
2011-04-09ld: 25% fasterRuss Cox
The ld time was dominated by symbol table processing, so * increase hash table size * emit fewer symbols in gc (just 1 per string, 1 per type) * add read-only lookup to avoid creating spurious symbols * add linked list to speed whole-table traversals Breaks dwarf generator (no idea why), so disable dwarf. Reduces time for 6l to link godoc by 25%. R=ken2 CC=golang-dev https://golang.org/cl/4383047
2011-02-248l/6l: new -Hwindowsgui flag allows to build windows gui peAlex Brainman
Fixes #1516. R=rsc, mattn CC=golang-dev https://golang.org/cl/4214041
2011-02-186l: pe fixesWei Guangjing
R=rsc, brainman CC=golang-dev https://golang.org/cl/4182061
2011-02-168l,6l: allow for more os threads to be created on WindowsAlex Brainman
Program listed http://code.google.com/p/go/issues/detail?id=1495 (with nRequester set to 10000) will crash with runtime: failed to create new OS thread (have 4526 already; errno=8) instead of runtime: failed to create new OS thread (have 618 already; errno=8). R=golang-dev, rsc, vcc CC=golang-dev https://golang.org/cl/4172046
2011-01-298l/6l: pe fixesAlex Brainman
- fixed length of amd64 .data pe section (don't need to include non-initialised data) - use correct oh/oh64 variable when updating data directory in addexports - simplify and cleanup R=vcc, rsc CC=golang-dev https://golang.org/cl/4106044
2011-01-278l: add PE dynexportWei Guangjing
R=rsc, brainman, mattn CC=golang-dev https://golang.org/cl/4022043
2011-01-208l: emit DWARF in Windows PE.Wei Guangjing
R=rsc, lvd, brainman, Joe Poirier CC=golang-dev https://golang.org/cl/2124041
2011-01-20cgo: windows/386 portWei Guangjing
R=rsc, peterGo, brainman CC=golang-dev https://golang.org/cl/3733046
2011-01-206l: windows/amd64 portWei Guangjing
R=rsc CC=golang-dev https://golang.org/cl/3746044
2011-01-198l: pe changesAlex Brainman
Dll names and function names padded to even size. Refactoring of imports writing code. R=rsc CC=golang-dev https://golang.org/cl/3804042
2010-12-078l : add dynimport to import table in Windows PE, initial make cgo dll work.Wei Guangjing
R=rsc, brainman, Joe Poirier, mattn CC=golang-dev https://golang.org/cl/2166041
2010-11-028l: pe generation fixesAlex Brainman
Restore ability to have different file and section alignment in generated pe file. Stop generating .bss pe section, it is part of .data now. Some code refactoring. R=rsc, vcc CC=golang-dev https://golang.org/cl/2731041
2010-10-208l: fix windows buildAlex Brainman
R=rsc CC=golang-dev https://golang.org/cl/2595041
2010-10-198l: fix references to INITDAT in windows pe.cRuss Cox
R=ken2 CC=golang-dev https://golang.org/cl/2588041
2010-10-195l, 6l, 8l: link pclntab and symtab as ordinary rodata symbolsRuss Cox
That is, move the pc/ln table and the symbol table into the read-only data segment. This eliminates the need for a special load command to map the symbol table into memory, which makes the information available on systems that couldn't handle the magic load to 0x99000000, like NaCl and ARM QEMU and Linux without config_highmem=y. It also eliminates an #ifdef and some clumsy code to find the symbol table on Windows. The bad news is that the binary appears to be bigger than it used to be. This is not actually the case, though: the same amount of data is being mapped into memory as before, and the tables are still read-only, so they're still shared across multiple instances of the binary as they were before. The difference is just that the tables aren't squirreled away in some section that "size" doesn't know to look at. This is a checkpoint. It probably breaks Windows and breaks NaCl more than it used to be broken, but those will be fixed. The logic involving -s needs to be revisited too. Fixes #871. R=ken2 CC=golang-dev https://golang.org/cl/2587041
2010-10-158l: fix windows build.Wei Guangjing
R=rsc, brainman CC=golang-dev https://golang.org/cl/2543042
2010-10-158l: blind attempt to fix windows buildRuss Cox
or at least gather more information R=ken2 CC=golang-dev https://golang.org/cl/2515042
2010-10-145l, 6l, 8l: accumulate data image during importRuss Cox
Using explicit relocations internally, we can represent the data for a particular symbol as an initialized block of memory instead of a linked list of ADATA instructions. The real goal here is to be able to hand off some of the relocations to the dynamic linker when interacting with system libraries, but a pleasant side effect is that the memory image is much more compact than the ADATA list, so the linkers use less memory. R=ken2 CC=golang-dev https://golang.org/cl/2512041
2010-04-138l: add DOS stub to PE binariesEvan Shaw
R=rsc CC=golang-dev https://golang.org/cl/915041
2010-02-108l: pe executable building code changed to include import table for ↵Alex Brainman
kernel32.dll functions Fixes #586. R=rsc CC=golang-dev https://golang.org/cl/203060
2010-02-01nacl: fix build, finally fixed 8l convergence bugRuss Cox
R=r CC=golang-dev https://golang.org/cl/199042
2009-12-138l: add support for PE output.Hector Chu
R=rsc https://golang.org/cl/166080