diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-12-21 10:00:23 -0800 |
---|---|---|
committer | Carlos Amedee <carlos@golang.org> | 2022-01-05 18:14:20 +0000 |
commit | ab70d7c799e07772e8c4e38336da00136d78b2e9 (patch) | |
tree | 731e3e56c75b9b8b028783815530cafd519fd182 /src | |
parent | 1242f430a94ade0f560dc218029b2c830f65e6a2 (diff) | |
download | go-ab70d7c799e07772e8c4e38336da00136d78b2e9.tar.gz go-ab70d7c799e07772e8c4e38336da00136d78b2e9.zip |
[release-branch.go1.17] cmd/link: use SHT_INIT_ARRAY for .init_array section
For #50295
Fixes #50297
Change-Id: If55ebcd5f2af724da7c9c744458a56d21a7ddde7
Reviewed-on: https://go-review.googlesource.com/c/go/+/373734
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
(cherry picked from commit cfb0cc355233d4367b188b23a3bc143985a28b8c)
Reviewed-on: https://go-review.googlesource.com/c/go/+/374194
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/link/internal/ld/elf.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/cmd/link/internal/ld/elf.go b/src/cmd/link/internal/ld/elf.go index d16539e4bf..de5d287947 100644 --- a/src/cmd/link/internal/ld/elf.go +++ b/src/cmd/link/internal/ld/elf.go @@ -1084,7 +1084,12 @@ func elfshbits(linkmode LinkMode, sect *sym.Section) *ElfShdr { } if sect.Vaddr < sect.Seg.Vaddr+sect.Seg.Filelen { - sh.Type = uint32(elf.SHT_PROGBITS) + switch sect.Name { + case ".init_array": + sh.Type = uint32(elf.SHT_INIT_ARRAY) + default: + sh.Type = uint32(elf.SHT_PROGBITS) + } } else { sh.Type = uint32(elf.SHT_NOBITS) } |