diff options
author | Matthew Dempsky <matthew@cvs.openbsd.org> | 2012-08-20 23:56:10 +0000 |
---|---|---|
committer | Matthew Dempsky <matthew@cvs.openbsd.org> | 2012-08-20 23:56:10 +0000 |
commit | 499b2ee6b6828b5801ca570a7eaa091bc88e645c (patch) | |
tree | de6f6395e1a4539e779cf9897e85eaf7ceb310f8 /gnu | |
parent | e8aa6e1c7aa4074e069f239019ca7c438fbe8fe6 (diff) |
Add support for .openbsd.randomdata and PT_OPENBSD_RANDOMIZE to
binutils 2.17. Passes randomdata regress tests on sparc64.
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/usr.bin/binutils-2.17/bfd/elf.c | 31 | ||||
-rw-r--r-- | gnu/usr.bin/binutils-2.17/binutils/readelf.c | 2 | ||||
-rw-r--r-- | gnu/usr.bin/binutils-2.17/include/elf/common.h | 2 | ||||
-rw-r--r-- | gnu/usr.bin/binutils-2.17/ld/scripttempl/elf.sc | 6 |
4 files changed, 40 insertions, 1 deletions
diff --git a/gnu/usr.bin/binutils-2.17/bfd/elf.c b/gnu/usr.bin/binutils-2.17/bfd/elf.c index de8228740b4..68d750b904b 100644 --- a/gnu/usr.bin/binutils-2.17/bfd/elf.c +++ b/gnu/usr.bin/binutils-2.17/bfd/elf.c @@ -1085,6 +1085,7 @@ get_segment_type (unsigned int p_type) case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break; case PT_GNU_STACK: pt = "STACK"; break; case PT_GNU_RELRO: pt = "RELRO"; break; + case PT_OPENBSD_RANDOMIZE: pt = "OPENBSD_RANDOMIZE"; break; default: pt = NULL; break; } return pt; @@ -2606,6 +2607,10 @@ bfd_section_from_phdr (bfd *abfd, Elf_Internal_Phdr *hdr, int index) case PT_GNU_RELRO: return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "relro"); + case PT_OPENBSD_RANDOMIZE: + return _bfd_elf_make_section_from_phdr (abfd, hdr, index, + "openbsd_randomize"); + default: /* Check for any processor-specific program segment types. */ bed = get_elf_backend_data (abfd); @@ -3605,7 +3610,7 @@ map_sections_to_segments (bfd *abfd) bfd_boolean writable; int tls_count = 0; asection *first_tls = NULL; - asection *dynsec, *eh_frame_hdr; + asection *dynsec, *eh_frame_hdr, *randomdata; bfd_size_type amt; if (elf_tdata (abfd)->segment_map != NULL) @@ -3918,6 +3923,24 @@ map_sections_to_segments (bfd *abfd) pm = &m->next; } + /* If there is a .openbsd.randomdata section, throw in a PT_OPENBSD_RANDOMIZE + segment. */ + randomdata = bfd_get_section_by_name (abfd, ".openbsd.randomdata"); + if (randomdata != NULL && (randomdata->flags & SEC_LOAD) != 0) + { + amt = sizeof (struct elf_segment_map); + m = bfd_zalloc (abfd, amt); + if (m == NULL) + goto error_return; + m->next = NULL; + m->p_type = PT_OPENBSD_RANDOMIZE; + m->count = 1; + m->sections[0] = randomdata->output_section; + + *pm = m; + pm = &m->next; + } + if (elf_tdata (abfd)->relro) { amt = sizeof (struct elf_segment_map); @@ -4650,6 +4673,12 @@ get_program_header_size (bfd *abfd) ++segs; } + if (bfd_get_section_by_name (abfd, ".openbsd.randomdata") != NULL) + { + /* We need a PT_OPENBSD_RANDOMDATA segment. */ + ++segs; + } + if (elf_tdata (abfd)->eh_frame_hdr) { /* We need a PT_GNU_EH_FRAME segment. */ diff --git a/gnu/usr.bin/binutils-2.17/binutils/readelf.c b/gnu/usr.bin/binutils-2.17/binutils/readelf.c index 78a417a06d6..214629a99cd 100644 --- a/gnu/usr.bin/binutils-2.17/binutils/readelf.c +++ b/gnu/usr.bin/binutils-2.17/binutils/readelf.c @@ -2372,6 +2372,8 @@ get_segment_type (unsigned long p_type) return "GNU_EH_FRAME"; case PT_GNU_STACK: return "GNU_STACK"; case PT_GNU_RELRO: return "GNU_RELRO"; + case PT_OPENBSD_RANDOMIZE: + return "OPENBSD_RANDOMIZE"; default: if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC)) diff --git a/gnu/usr.bin/binutils-2.17/include/elf/common.h b/gnu/usr.bin/binutils-2.17/include/elf/common.h index 2e43fcebd79..2432daf4daa 100644 --- a/gnu/usr.bin/binutils-2.17/include/elf/common.h +++ b/gnu/usr.bin/binutils-2.17/include/elf/common.h @@ -305,6 +305,8 @@ #define PT_GNU_STACK (PT_LOOS + 0x474e551) /* Stack flags */ #define PT_GNU_RELRO (PT_LOOS + 0x474e552) /* Read-only after relocation */ +#define PT_OPENBSD_RANDOMIZE 0x65a3dbe6 /* Fill with random data. */ + /* Program segment permissions, in program header p_flags field. */ #define PF_X (1 << 0) /* Segment is executable */ diff --git a/gnu/usr.bin/binutils-2.17/ld/scripttempl/elf.sc b/gnu/usr.bin/binutils-2.17/ld/scripttempl/elf.sc index ac0c7256e2e..bac89596b0f 100644 --- a/gnu/usr.bin/binutils-2.17/ld/scripttempl/elf.sc +++ b/gnu/usr.bin/binutils-2.17/ld/scripttempl/elf.sc @@ -396,6 +396,12 @@ cat <<EOF KEEP (*(SORT(.fini_array.*))) ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__fini_array_end = .);}} } + .openbsd.randomdata ${RELOCATING-0} : + { + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__openbsd_randomdata_start = .);}} + *(.openbsd.randomdata${RELOCATING+ .openbsd.randomdata.*}) + ${RELOCATING+${CREATE_SHLIB-PROVIDE_HIDDEN (__openbsd_randomdata_end = .);}} + } ${SMALL_DATA_CTOR-${RELOCATING+${CTOR}}} ${SMALL_DATA_DTOR-${RELOCATING+${DTOR}}} .jcr ${RELOCATING-0} : { KEEP (*(.jcr)) } |