diff options
author | Richard Sandiford <rdsandiford@googlemail.com> | 2006-10-20 07:57:03 +0000 |
---|---|---|
committer | Richard Sandiford <rdsandiford@googlemail.com> | 2006-10-20 07:57:03 +0000 |
commit | 98c904a8640de8891570902ac9d1ef6153092a18 (patch) | |
tree | d3417b6c2e1b4ed258185a95cd7c54f9e41cc6b7 /bfd/elfxx-mips.c | |
parent | 5427f821ae3f03e66f93914e805284a08dbc0df1 (diff) | |
download | gdb-98c904a8640de8891570902ac9d1ef6153092a18.zip gdb-98c904a8640de8891570902ac9d1ef6153092a18.tar.gz gdb-98c904a8640de8891570902ac9d1ef6153092a18.tar.bz2 |
bfd/
* elfxx-mips.c (_bfd_mips_elf_additional_program_headers): Allocate
a PT_NULL header for dynamic objects.
(_bfd_mips_elf_modify_segment_map): Add it.
ld/testsuite/
* ld-mips-elf/multi-got-1.d: Do not expect a particular address
for DT_HASH.
* ld-mips-elf/rel32-o32.d: Bump addresses by 0x20 to account for
the extra program header.
* ld-mips-elf/rel32-n32.d: Likewise.
* ld-mips-elf/tlslib-o32.got: Likewise.
* ld-mips-elf/tlslib-o32-hidden.got: Likewise.
* ld-mips-elf/tlslib-o32-ver.got: Likewise.
* ld-mips-elf/tls-multi-got-1.got: Likewise.
* ld-mips-elf/tls-multi-got-1.r: Likewise.
* ld-mips-elf/rel64.d: Bump addresses by 0x30 to account for the
extra program header.
* ld-mips-elf/tlsdyn-o32.d: Reduce the GOT offset by 32 to account
for the extra program header, and thus the shorter gap between the
text and data segments.
* ld-mips-elf/tlsdyn-o32-1.d: Likewise.
* ld-mips-elf/tlsdyn-o32-2.d: Likewise.
* ld-mips-elf/tlsdyn-o32-3.d: Likewise.
* ld-mips-elf/tlsdyn-o32.got: Bump GOT text addresses by 0x20
to account for the extra program header.
* ld-mips-elf/tlsdyn-o32-1.got: Likewise.
* ld-mips-elf/tlsdyn-o32-2.got: Likewise.
* ld-mips-elf/tlsdyn-o32-3.got: Likewise.
Diffstat (limited to 'bfd/elfxx-mips.c')
-rw-r--r-- | bfd/elfxx-mips.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 33b0e43..639a065 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -9169,6 +9169,12 @@ _bfd_mips_elf_additional_program_headers (bfd *abfd, && bfd_get_section_by_name (abfd, ".mdebug")) ++ret; + /* Allocate a PT_NULL header in dynamic objects. See + _bfd_mips_elf_modify_segment_map for details. */ + if (!SGI_COMPAT (abfd) + && bfd_get_section_by_name (abfd, ".dynamic")) + ++ret; + return ret; } @@ -9377,6 +9383,38 @@ _bfd_mips_elf_modify_segment_map (bfd *abfd, } } + /* Allocate a spare program header in dynamic objects so that tools + like the prelinker can add an extra PT_LOAD entry. + + If the prelinker needs to make room for a new PT_LOAD entry, its + standard procedure is to move the first (read-only) sections into + the new (writable) segment. However, the MIPS ABI requires + .dynamic to be in a read-only segment, and the section will often + start within sizeof (ElfNN_Phdr) bytes of the last program header. + + Although the prelinker could in principle move .dynamic to a + writable segment, it seems better to allocate a spare program + header instead, and avoid the need to move any sections. + There is a long tradition of allocating spare dynamic tags, + so allocating a spare program header seems like a natural + extension. */ + if (!SGI_COMPAT (abfd) + && bfd_get_section_by_name (abfd, ".dynamic")) + { + for (pm = &elf_tdata (abfd)->segment_map; *pm != NULL; pm = &(*pm)->next) + if ((*pm)->p_type == PT_NULL) + break; + if (*pm == NULL) + { + m = bfd_zalloc (abfd, sizeof (*m)); + if (m == NULL) + return FALSE; + + m->p_type = PT_NULL; + *pm = m; + } + } + return TRUE; } |