--- /dev/null
+pkg debug/elf, const PT_OPENBSD_NOBTCFI = 1705237480 #66054
+pkg debug/elf, const PT_OPENBSD_NOBTCFI ProgType #66054
--- /dev/null
+The debug/elf package now defines PT_OPENBSD_NOBTCFI. This elf.ProgType is
+used to disable Branch Tracking Control Flow Integrity (BTCFI) enforcement
+on OpenBSD binaries.
ph.Type = elf.PT_GNU_STACK
ph.Flags = elf.PF_W + elf.PF_R
ph.Align = uint64(ctxt.Arch.RegSize)
+ } else if ctxt.HeadType == objabi.Hopenbsd {
+ ph := newElfPhdr()
+ ph.Type = elf.PT_OPENBSD_NOBTCFI
+ ph.Flags = elf.PF_X
} else if ctxt.HeadType == objabi.Hsolaris {
ph := newElfPhdr()
ph.Type = elf.PT_SUNWSTACK
}
case objabi.Hopenbsd:
argv = append(argv, "-Wl,-nopie")
+ if linkerFlagSupported(ctxt.Arch, argv[0], "", "-Wl,-z,nobtcfi") {
+ // -Wl,-z,nobtcfi is only supported on OpenBSD 7.4+, remove guard
+ // when OpenBSD 7.5 is released and 7.3 is no longer supported.
+ argv = append(argv, "-Wl,-z,nobtcfi")
+ }
argv = append(argv, "-pthread")
if ctxt.Arch.InFamily(sys.ARM64) {
// Disable execute-only on openbsd/arm64 - the Go arm64 assembler
PT_OPENBSD_RANDOMIZE ProgType = 0x65a3dbe6 /* Random data */
PT_OPENBSD_WXNEEDED ProgType = 0x65a3dbe7 /* W^X violations */
+ PT_OPENBSD_NOBTCFI ProgType = 0x65a3dbe8 /* No branch target CFI */
PT_OPENBSD_BOOTDATA ProgType = 0x65a41be6 /* Boot arguments */
PT_SUNW_EH_FRAME ProgType = 0x6474e550 /* Frame unwind information */