Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: TestPIESize-internal is broken on openbsd/arm64 after DWARF v5 was enabled #72818

Closed
4a6f656c opened this issue Mar 12, 2025 · 2 comments
Labels
BugReport Issues describing a possible bug in the Go implementation. compiler/runtime Issues related to the Go compiler and/or runtime.

Comments

@4a6f656c
Copy link
Contributor

After DWARF v5 was enabled (https://go-review.googlesource.com/c/go/+/637895), the TestPIESize-internal test fails on openbsd/arm64 with:

 --- FAIL: TestPIESize (0.02s)
    --- FAIL: TestPIESize/TestPieSize-internal (1.41s)
        elf_test.go:390: [/home/joel/src/go/bin/go build -o /tmp/TestPIESizeTestPieSize-internal2328146593/001/pie -buildmode=pie pie.go]
        elf_test.go:390: [/home/joel/src/go/bin/go build -o /tmp/TestPIESizeTestPieSize-internal2328146593/001/exe -buildmode=exe pie.go]
        elf_test.go:518: real size difference 0xe99d7, expected 0x2ce89
        elf_test.go:521: PIE unexpectedly large: got difference of 956887 (3247600 - 2292553), expected difference 183945

https://build.golang.org/log/7ebefb5b8293420696f54d3709dbb0e098b0492e

It is worth noting that running with -buildmode=pie does result in external linking being enabled - i.e. InternalLinkPIESupported("openbsd", "arm64") is false.

The program headers for the two binaries are:

$ readelf -l /tmp/exe

Elf file type is EXEC (Executable file)
Entry point 0x7cd30
There are 10 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000010040 0x0000000000010040
                 0x0000000000000230 0x0000000000000230  R      10000
  INTERP         0x0000000000000fed 0x0000000000010fed 0x0000000000010fed
                 0x0000000000000013 0x0000000000000013  R      1
      [Requesting program interpreter: /usr/libexec/ld.so]
  NOTE           0x0000000000000fd4 0x0000000000010fd4 0x0000000000010fd4
                 0x0000000000000018 0x0000000000000018  R      4
  NOTE           0x0000000000000f4c 0x0000000000010f4c 0x0000000000010f4c
                 0x0000000000000064 0x0000000000000064  R      4
  LOAD           0x0000000000000000 0x0000000000010000 0x0000000000010000
                 0x000000000009b5a0 0x000000000009b5a0  R E    10000
  LOAD           0x00000000000a0000 0x00000000000b0000 0x00000000000b0000
                 0x00000000000cb7d0 0x00000000000cb7d0  R      10000
  LOAD           0x0000000000170000 0x0000000000180000 0x0000000000180000
                 0x000000000000a5c0 0x000000000003e040  RW     10000
  DYNAMIC        0x00000000001701e0 0x00000000001801e0 0x00000000001801e0
                 0x0000000000000110 0x0000000000000110  RW     8
  TLS            0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000010  R      8
  OPENBSD_NOBTCF 0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000    E    0
$ readelf -l /tmp/pie 
                                                         
Elf file type is DYN (Shared object file)
Entry point 0x65fa0
There are 14 program headers, starting at offset 64                                                               
                                                         
Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000000040 0x0000000000000040
                 0x0000000000000310 0x0000000000000310  R      8
  INTERP         0x0000000000000350 0x0000000000000350 0x0000000000000350
                 0x0000000000000013 0x0000000000000013  R      1
      [Requesting program interpreter: /usr/libexec/ld.so]
  LOAD           0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000055f98 0x0000000000055f98  R      10000
  LOAD           0x0000000000055fa0 0x0000000000065fa0 0x0000000000065fa0
                 0x000000000009bc70 0x000000000009bc70  R E    10000
  LOAD           0x00000000000f1c10 0x0000000000111c10 0x0000000000111c10
                 0x00000000000a2d20 0x00000000000a2d20  RW     10000
  LOAD           0x0000000000194930 0x00000000001c4930 0x00000000001c4930
                 0x000000000000a382 0x000000000003de70  RW     10000
  TLS            0x00000000000f1c10 0x0000000000101c10 0x0000000000101c10
                 0x0000000000000000 0x0000000000000010  R      8
  DYNAMIC        0x00000000001945d0 0x00000000001b45d0 0x00000000001b45d0
                 0x0000000000000130 0x0000000000000130  RW     8
  GNU_RELRO      0x00000000000f1c10 0x0000000000111c10 0x0000000000111c10
                 0x00000000000a2d20 0x00000000000a33f0  R      1
  GNU_EH_FRAME   0x0000000000055ae8 0x0000000000055ae8 0x0000000000055ae8
                 0x00000000000000c4 0x00000000000000c4  R      4
  OPENBSD_RANDOM 0x00000000000f1c10 0x0000000000111c10 0x0000000000111c10
                 0x0000000000000028 0x0000000000000028  RW     8
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     0
  OPENBSD_NOBTCF 0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000    E    0
  NOTE           0x0000000000000364 0x0000000000000364 0x0000000000000364
                 0x00000000000000a0 0x00000000000000a0  R      4

Seemingly this passed previously but does not now - does it make sense to compare apples with oranges^W^W^Winternally linked PIE mode with externally linked PIE mode, or should this just skip the internal test if InternalLinkPIESupported returns false?

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Mar 12, 2025
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/657035 mentions this issue: cmd/link: only check PIE size difference when the linkmode is the same

@gabyhelp gabyhelp added the BugReport Issues describing a possible bug in the Go implementation. label Mar 12, 2025
@github-project-automation github-project-automation bot moved this from Todo to Done in Go Compiler / Runtime Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugReport Issues describing a possible bug in the Go implementation. compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
Development

No branches or pull requests

3 participants