1*8b424531Smortimer$OpenBSD: SPECS.randomdata,v 1.3 2018/06/01 03:27:59 mortimer Exp $ 25f706690Smatthew 35f706690SmatthewThis document describes the OpenBSD operating system supplement for 45f706690Smatthewadding "random data" sections to the ELF ABI. These sections can be 55f706690Smatthewuseful for holding values like GCC's stack-smashing protector cookies 65f706690Smatthewand offer additional benefits like ensuring the data is initialized 75f706690Smatthewbefore any constructor methods are called and allowing the dynamic 85f706690Smatthewlinker to mark the memory as read-only after initialization. 95f706690Smatthew 105f706690Smatthew 115f706690SmatthewProgram Header 125f706690Smatthew 135f706690SmatthewOpenBSD defines the following operating system-specific segment type: 145f706690Smatthew 155f706690Smatthew Name Value 165f706690Smatthew PT_OPENBSD_RANDOMIZE 0x65a3dbe6 175f706690Smatthew 185f706690Smatthew 195f706690Smatthew PT_OPENBSD_RANDOMIZE 205f706690Smatthew 215f706690Smatthew The array element specifies the location and size of a random data 225f706690Smatthew section. The system will initialize the specified memory range 235f706690Smatthew with random data. The memory range must be separately mapped 245f706690Smatthew (e.g., by use of a PT_LOAD segment). 255f706690Smatthew 265f706690Smatthew 275f706690SmatthewSpecial Sections 285f706690Smatthew 295f706690SmatthewOpenBSD defines the following operating system-specific special 305f706690Smatthewsections: 315f706690Smatthew 325f706690Smatthew Name Type Attributes 335f706690Smatthew .openbsd.randomdata SHT_PROGBITS SHF_ALLOC 345f706690Smatthew 355f706690Smatthew 365f706690Smatthew .openbsd.randomdata 375f706690Smatthew 385f706690Smatthew This section holds the random data section. 395f706690Smatthew 405f706690Smatthew 415f706690SmatthewImplementation Notes 425f706690Smatthew 435f706690SmatthewOn OpenBSD, PT_OPENBSD_RANDOMIZE segments are handled alongside 445f706690SmatthewPT_LOAD segments: the kernel handles initializing random data segments 455f706690Smatthewin executables and program interpreters (i.e., ld.so), while ld.so 465f706690Smatthewhandles initializing them in shared libraries. Additionally, the 475f706690Smatthewkernel limits the total number of PT_OPENBSD_RANDOMIZE segment bytes 48*8b424531Smortimerin an executable or interpreter to 1048576 bytes. 49