Please sign in to comment.
cmd/link: insert trampolines for too-far jumps on ARM
ARM direct CALL/JMP instruction has 24 bit offset, which can only encodes jumps within +/-32M. When the target is too far, the top bits get truncated and the program jumps wild. This CL detects too-far jumps and automatically insert trampolines, currently only internal linking on ARM. It is necessary to make the following changes to the linker: - Resolve direct jump relocs when assigning addresses to functions. this allows trampoline insertion without moving all code that already laid down. - Lay down packages in dependency order, so that when resolving a inter-package direct jump reloc, the target address is already known. Intra-package jumps are assumed never too far. - a linker flag -debugtramp is added for debugging trampolines: "-debugtramp=1 -v" prints trampoline debug message "-debugtramp=2" forces all inter-package jump to use trampolines (currently ARM only) "-debugtramp=2 -v" does both - Some data structures are changed for bookkeeping. On ARM, pseudo DIV/DIVU/MOD/MODU instructions now clobber R8 (unfortunate). In the standard library there is no ARM assembly code that uses these instructions, and the compiler no longer emits them (CL 29390). all.bash passes with -debugtramp=2, except a disassembly test (this is unavoidable as we changed the instruction). TBD: debug info of trampolines? Fixes #17028. Change-Id: Idcce347ea7e0af77c4079041a160b2f6e114b474 Reviewed-on: https://go-review.googlesource.com/29397 Reviewed-by: David Crawshaw <email@example.com> Run-TryBot: Cherry Zhang <firstname.lastname@example.org> TryBot-Result: Gobot Gobot <email@example.com>
- Loading branch information...
Showing with 353 additions and 106 deletions.
- +2 −2 src/cmd/internal/obj/arm/obj5.go
- +14 −0 src/cmd/internal/obj/link.go
- +1 −1 src/cmd/link/internal/amd64/asm.go
- +69 −6 src/cmd/link/internal/arm/asm.go
- +1 −0 src/cmd/link/internal/arm/obj.go
- +2 −1 src/cmd/link/internal/ld/ar.go
- +122 −34 src/cmd/link/internal/ld/data.go
- +4 −1 src/cmd/link/internal/ld/deadcode.go
- +8 −8 src/cmd/link/internal/ld/ld.go
- +75 −27 src/cmd/link/internal/ld/lib.go
- +15 −6 src/cmd/link/internal/ld/link.go
- +1 −0 src/cmd/link/internal/ld/main.go
- +23 −9 src/cmd/link/internal/ld/objfile.go
- +4 −2 src/cmd/link/internal/x86/asm.go
- +4 −2 src/runtime/proc.go
- +8 −7 src/runtime/vlop_arm.s
Oops, something went wrong.