Don't add PHDR for objcopy/strip or ld script specifying PHDRS
HPPA64 needs to add a DT_PHDR header for shared libs. That's fine when linking but shouldn't happen for strip/objcopy. Also PHDR must come first so there's no need to look at all program headers. bfd/ * elf64-hppa.c (elf64_hppa_modify_segment_map): Don't add PHDR for objcopy/strip or when a ld script specifies PHDRS. ld/ * testsuite/ld-elf/nobits-1.d: Remove xfail for hppa64. * testsuite/ld-elf/note-1.d: Likewise. * testsuite/ld-elf/note-2.d: Likewise.
This commit is contained in:
parent
6392030005
commit
22b05d33b4
|
@ -1,3 +1,8 @@
|
||||||
|
2016-12-13 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* elf64-hppa.c (elf64_hppa_modify_segment_map): Don't add PHDR
|
||||||
|
for objcopy/strip or when a ld script specifies PHDRS.
|
||||||
|
|
||||||
2016-12-13 Alan Modra <amodra@gmail.com>
|
2016-12-13 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* elf32-rx.c (elf32_rx_modify_program_headers): Don't adjust
|
* elf32-rx.c (elf32_rx_modify_program_headers): Don't adjust
|
||||||
|
|
|
@ -2688,38 +2688,29 @@ elf64_hppa_allow_non_load_phdr (bfd *abfd ATTRIBUTE_UNUSED,
|
||||||
existence of a .interp section. */
|
existence of a .interp section. */
|
||||||
|
|
||||||
static bfd_boolean
|
static bfd_boolean
|
||||||
elf64_hppa_modify_segment_map (bfd *abfd,
|
elf64_hppa_modify_segment_map (bfd *abfd, struct bfd_link_info *info)
|
||||||
struct bfd_link_info *info ATTRIBUTE_UNUSED)
|
|
||||||
{
|
{
|
||||||
struct elf_segment_map *m;
|
struct elf_segment_map *m;
|
||||||
asection *s;
|
|
||||||
|
|
||||||
s = bfd_get_section_by_name (abfd, ".interp");
|
m = elf_seg_map (abfd);
|
||||||
if (! s)
|
if (info != NULL && !info->user_phdrs && m != NULL && m->p_type != PT_PHDR)
|
||||||
{
|
{
|
||||||
for (m = elf_seg_map (abfd); m != NULL; m = m->next)
|
m = ((struct elf_segment_map *)
|
||||||
if (m->p_type == PT_PHDR)
|
bfd_zalloc (abfd, (bfd_size_type) sizeof *m));
|
||||||
break;
|
|
||||||
|
|
||||||
if (m == NULL)
|
if (m == NULL)
|
||||||
{
|
return FALSE;
|
||||||
m = ((struct elf_segment_map *)
|
|
||||||
bfd_zalloc (abfd, (bfd_size_type) sizeof *m));
|
|
||||||
if (m == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
m->p_type = PT_PHDR;
|
m->p_type = PT_PHDR;
|
||||||
m->p_flags = PF_R | PF_X;
|
m->p_flags = PF_R | PF_X;
|
||||||
m->p_flags_valid = 1;
|
m->p_flags_valid = 1;
|
||||||
m->p_paddr_valid = 1;
|
m->p_paddr_valid = 1;
|
||||||
m->includes_phdrs = 1;
|
m->includes_phdrs = 1;
|
||||||
|
|
||||||
m->next = elf_seg_map (abfd);
|
m->next = elf_seg_map (abfd);
|
||||||
elf_seg_map (abfd) = m;
|
elf_seg_map (abfd) = m;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (m = elf_seg_map (abfd); m != NULL; m = m->next)
|
for (m = elf_seg_map (abfd) ; m != NULL; m = m->next)
|
||||||
if (m->p_type == PT_LOAD)
|
if (m->p_type == PT_LOAD)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2016-12-13 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* testsuite/ld-elf/nobits-1.d: Remove xfail for hppa64.
|
||||||
|
* testsuite/ld-elf/note-1.d: Likewise.
|
||||||
|
* testsuite/ld-elf/note-2.d: Likewise.
|
||||||
|
|
||||||
2016-12-13 Alan Modra <amodra@gmail.com>
|
2016-12-13 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* testsuite/ld-elf/flags1.d: Run for RX.
|
* testsuite/ld-elf/flags1.d: Run for RX.
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#ld: -Tnobits-1.t
|
#ld: -Tnobits-1.t
|
||||||
#readelf: -l --wide
|
#readelf: -l --wide
|
||||||
#xfail: hppa64-*-*
|
|
||||||
# hppa64 adds PHDR
|
|
||||||
|
|
||||||
#...
|
#...
|
||||||
Section to Segment mapping:
|
Section to Segment mapping:
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#ld: -Tnote-1.t
|
#ld: -Tnote-1.t
|
||||||
#readelf: -l --wide
|
#readelf: -l --wide
|
||||||
#xfail: hppa64-*-*
|
|
||||||
# hppa64 adds PHDR
|
|
||||||
|
|
||||||
#...
|
#...
|
||||||
Section to Segment mapping:
|
Section to Segment mapping:
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#ld: -Tnote-2.t
|
#ld: -Tnote-2.t
|
||||||
#objcopy_linked_file: -R .foo
|
#objcopy_linked_file: -R .foo
|
||||||
#readelf: -l --wide
|
#readelf: -l --wide
|
||||||
#xfail: hppa64-*-*
|
|
||||||
# hppa64 adds PHDR
|
|
||||||
|
|
||||||
#...
|
#...
|
||||||
Program Headers:
|
Program Headers:
|
||||||
|
|
Loading…
Reference in New Issue