diff options
author | Ayke van Laethem <[email protected]> | 2020-04-14 22:43:32 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2020-10-13 20:23:50 +0200 |
commit | b40f250530769330cec4a2ae0a9ba6e0c6ce058a (patch) | |
tree | 83736ddcb5df3c00ef0b95bb41482c9e77133c86 /builder/objcopy.go | |
parent | 184175378f56e8ad03b6048fb40f5138e9710adb (diff) | |
download | tinygo-b40f250530769330cec4a2ae0a9ba6e0c6ce058a.tar.gz tinygo-b40f250530769330cec4a2ae0a9ba6e0c6ce058a.zip |
main: add initial support for (in-development) LLVM 11
This can be useful to test improvements in LLVM master and to make it
possible to support LLVM 11 for the most part already before the next
release. That also allows catching LLVM bugs early to fix them upstream.
Note that tests do not yet pass for this LLVM version, but the TinyGo
compiler can be built with the binaries from apt.llvm.org (at the time
of making this commit).
Diffstat (limited to 'builder/objcopy.go')
-rw-r--r-- | builder/objcopy.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/builder/objcopy.go b/builder/objcopy.go index a8a76afa9..991bceba5 100644 --- a/builder/objcopy.go +++ b/builder/objcopy.go @@ -61,7 +61,7 @@ func extractROM(path string) (uint64, []byte, error) { progs := make(progSlice, 0, 2) for _, prog := range f.Progs { - if prog.Type != elf.PT_LOAD || prog.Filesz == 0 { + if prog.Type != elf.PT_LOAD || prog.Filesz == 0 || prog.Off == 0 { continue } progs = append(progs, prog) @@ -73,6 +73,12 @@ func extractROM(path string) (uint64, []byte, error) { var rom []byte for _, prog := range progs { + romEnd := progs[0].Paddr + uint64(len(rom)) + if prog.Paddr > romEnd && prog.Paddr < romEnd+16 { + // Sometimes, the linker seems to insert a bit of padding between + // segments. Simply zero-fill these parts. + rom = append(rom, make([]byte, prog.Paddr-romEnd)...) + } if prog.Paddr != progs[0].Paddr+uint64(len(rom)) { diff := prog.Paddr - (progs[0].Paddr + uint64(len(rom))) if diff > maxPadBytes { |