forked from Imagelibrary/binutils-gdb
binutils/
* readelf.c (get_segment_type): Handle PT_GNU_STACK.
bfd/
* elf.c (_bfd_elf_print_private_bfd_data): Handle PT_GNU_STACK.
(bfd_section_from_phdr): Likewise.
(map_sections_to_segments): Create PT_GNU_STACK segment header.
(get_program_header_size): Count with PT_GNU_STACK.
* elf-bfd.h (struct elf_obj_tdata): Add stack_flags.
* elflink.h (bfd_elfNN_size_dynamic_sections): Set stack_flags.
include/
* bfdlink.h (struct bfd_link_info): Add execstack and noexecstack.
* elf/common.h (PT_GNU_STACK): Define.
ld/
* ldgram.y (phdr_type): Grok PT_GNU_STACK.
* emultempl/elf32.em (gld${EMULATION_NAME}_handle_option): Add
-z execstack and -z noexecstack.
(gld${EMULATION_NAME}_list_options): Likewise.
* scripttempl/elf.sc: If not -r, discard .note.GNU-stack section.
This commit is contained in:
25
bfd/elf.c
25
bfd/elf.c
@@ -1070,6 +1070,7 @@ _bfd_elf_print_private_bfd_data (abfd, farg)
|
||||
case PT_PHDR: pt = "PHDR"; break;
|
||||
case PT_TLS: pt = "TLS"; break;
|
||||
case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break;
|
||||
case PT_GNU_STACK: pt = "STACK"; break;
|
||||
default: sprintf (buf, "0x%lx", p->p_type); pt = buf; break;
|
||||
}
|
||||
fprintf (f, "%8s off 0x", pt);
|
||||
@@ -2296,6 +2297,9 @@ bfd_section_from_phdr (abfd, hdr, index)
|
||||
return _bfd_elf_make_section_from_phdr (abfd, hdr, index,
|
||||
"eh_frame_hdr");
|
||||
|
||||
case PT_GNU_STACK:
|
||||
return _bfd_elf_make_section_from_phdr (abfd, hdr, index, "stack");
|
||||
|
||||
default:
|
||||
/* Check for any processor-specific program segment types.
|
||||
If no handler for them, default to making "segment" sections. */
|
||||
@@ -3513,6 +3517,21 @@ map_sections_to_segments (abfd)
|
||||
pm = &m->next;
|
||||
}
|
||||
|
||||
if (elf_tdata (abfd)->stack_flags)
|
||||
{
|
||||
amt = sizeof (struct elf_segment_map);
|
||||
m = (struct elf_segment_map *) bfd_zalloc (abfd, amt);
|
||||
if (m == NULL)
|
||||
goto error_return;
|
||||
m->next = NULL;
|
||||
m->p_type = PT_GNU_STACK;
|
||||
m->p_flags = elf_tdata (abfd)->stack_flags;
|
||||
m->p_flags_valid = 1;
|
||||
|
||||
*pm = m;
|
||||
pm = &m->next;
|
||||
}
|
||||
|
||||
free (sections);
|
||||
sections = NULL;
|
||||
|
||||
@@ -4099,6 +4118,12 @@ get_program_header_size (abfd)
|
||||
++segs;
|
||||
}
|
||||
|
||||
if (elf_tdata (abfd)->stack_flags)
|
||||
{
|
||||
/* We need a PT_GNU_STACK segment. */
|
||||
++segs;
|
||||
}
|
||||
|
||||
for (s = abfd->sections; s != NULL; s = s->next)
|
||||
{
|
||||
if ((s->flags & SEC_LOAD) != 0
|
||||
|
||||
Reference in New Issue
Block a user