the -z nobtcfi option.
ok deraadt@
bool zInitfirst;
bool zInterpose;
bool zKeepTextSectionPrefix;
+ bool zNoBtCfi;
bool zNodefaultlib;
bool zNodelete;
bool zNodlopen;
s == "initfirst" || s == "interpose" ||
s == "keep-text-section-prefix" || s == "lazy" || s == "muldefs" ||
s == "separate-code" || s == "separate-loadable-segments" ||
- s == "start-stop-gc" || s == "nocombreloc" || s == "nocopyreloc" ||
+ s == "start-stop-gc" || s == "nobtcfi" ||
+ s == "nocombreloc" || s == "nocopyreloc" ||
s == "nodefaultlib" || s == "nodelete" || s == "nodlopen" ||
s == "noexecstack" || s == "nognustack" ||
s == "nokeep-text-section-prefix" || s == "norelro" ||
config->zInterpose = hasZOption(args, "interpose");
config->zKeepTextSectionPrefix = getZFlag(
args, "keep-text-section-prefix", "nokeep-text-section-prefix", false);
+ config->zNoBtCfi = hasZOption(args, "nobtcfi");
config->zNodefaultlib = hasZOption(args, "nodefaultlib");
config->zNodelete = hasZOption(args, "nodelete");
config->zNodlopen = hasZOption(args, "nodlopen");
if (config->zWxneeded)
addHdr(PT_OPENBSD_WXNEEDED, PF_X);
+ // PT_OPENBSD_NOBTCFI is an OpenBSD-specific header to mark that the
+ // executable is expected to violate branch-target CFI checks.
+ if (config->zNoBtCfi)
+ addHdr(PT_OPENBSD_NOBTCFI, PF_X);
+
if (OutputSection *cmd = findSection(".note.gnu.property", partNo))
addHdr(PT_GNU_PROPERTY, PF_R)->add(cmd);
PT_OPENBSD_MUTABLE = 0x65a3dbe5, // Like bss, but not immutable.
PT_OPENBSD_RANDOMIZE = 0x65a3dbe6, // Fill with random data.
PT_OPENBSD_WXNEEDED = 0x65a3dbe7, // Program does W^X violations.
+ PT_OPENBSD_NOBTCFI = 0x65a3dbe8, // Do not enforce branch target CFI
PT_OPENBSD_BOOTDATA = 0x65a41be6, // Section for boot arguments.
// ARM program header types.
case ELF::PT_OPENBSD_MUTABLE:
outs() << "OPENBSD_MUTABLE ";
break;
+ case ELF::PT_OPENBSD_NOBTCFI:
+ outs() << "OPENBSD_NOBTCFI ";
+ break;
case ELF::PT_OPENBSD_RANDOMIZE:
outs() << "OPENBSD_RANDOMIZE ";
break;
LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_MUTABLE);
LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_RANDOMIZE);
LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_WXNEEDED);
+ LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_NOBTCFI);
LLVM_READOBJ_ENUM_CASE(ELF, PT_OPENBSD_BOOTDATA);
default:
return "";