diff options
author | Alan Modra <amodra@gmail.com> | 2011-04-11 04:08:13 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2011-04-11 04:08:13 +0000 |
commit | e57278ef9d811d78f6db04a11ea4810ca6ae2575 (patch) | |
tree | 5d4cef8d28e53b1531921e76c259b68618281c52 /bfd | |
parent | 6edcf5b8e0d9b18f11019d87bf217924abbe3322 (diff) | |
download | gdb-e57278ef9d811d78f6db04a11ea4810ca6ae2575.zip gdb-e57278ef9d811d78f6db04a11ea4810ca6ae2575.tar.gz gdb-e57278ef9d811d78f6db04a11ea4810ca6ae2575.tar.bz2 |
* bfd-in.h (bfd_get_section_limit): Don't use rawsize with output
sections.
* libbfd.c (_bfd_generic_get_section_contents): Likewise.
(_bfd_generic_get_section_contents_in_window): Likewise.
* section.c (bfd_get_section_contents): Likewise.
* compress.c (bfd_get_full_section_contents): Likewise.
* elf32-rx.c (rx_final_link): Ignore rawsize.
* elf32-microblaze.c (microblaze_elf_relocate_section): Use correct
bfd with bfd_get_section_limit.
* elfxx-ia64.c (elfNN_ia64_choose_gp): Add "final" parameter. Use
os->size during final link. Update callers.
* bfd-in2.h: Regenerate.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 15 | ||||
-rw-r--r-- | bfd/bfd-in.h | 8 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 8 | ||||
-rw-r--r-- | bfd/compress.c | 8 | ||||
-rw-r--r-- | bfd/elf32-microblaze.c | 4 | ||||
-rw-r--r-- | bfd/elf32-rx.c | 5 | ||||
-rw-r--r-- | bfd/elfxx-ia64.c | 17 | ||||
-rw-r--r-- | bfd/libbfd.c | 15 | ||||
-rw-r--r-- | bfd/section.c | 7 |
9 files changed, 62 insertions, 25 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index eaea8f2..3730ee7 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,18 @@ +2011-04-11 Alan Modra <amodra@gmail.com> + + * bfd-in.h (bfd_get_section_limit): Don't use rawsize with output + sections. + * libbfd.c (_bfd_generic_get_section_contents): Likewise. + (_bfd_generic_get_section_contents_in_window): Likewise. + * section.c (bfd_get_section_contents): Likewise. + * compress.c (bfd_get_full_section_contents): Likewise. + * elf32-rx.c (rx_final_link): Ignore rawsize. + * elf32-microblaze.c (microblaze_elf_relocate_section): Use correct + bfd with bfd_get_section_limit. + * elfxx-ia64.c (elfNN_ia64_choose_gp): Add "final" parameter. Use + os->size during final link. Update callers. + * bfd-in2.h: Regenerate. + 2011-04-10 Richard Sandiford <rdsandiford@googlemail.com> PR ld/12637 diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index 63fcdc9..5f0f4b5 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -1,7 +1,7 @@ /* Main header file for the bfd library -- portable access to object files. - Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, + 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Contributed by Cygnus Support. @@ -291,8 +291,8 @@ typedef struct bfd_section *sec_ptr; #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE) /* Find the address one past the end of SEC. */ #define bfd_get_section_limit(bfd, sec) \ - (((sec)->rawsize ? (sec)->rawsize : (sec)->size) \ - / bfd_octets_per_byte (bfd)) + (((bfd)->direction != write_direction && (sec)->rawsize != 0 \ + ? (sec)->rawsize : (sec)->size) / bfd_octets_per_byte (bfd)) /* Return TRUE if input section SEC has been discarded. */ #define elf_discarded_section(sec) \ diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index a1ef1c1..e7c410d 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -7,8 +7,8 @@ /* Main header file for the bfd library -- portable access to object files. - Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, + 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Contributed by Cygnus Support. @@ -298,8 +298,8 @@ typedef struct bfd_section *sec_ptr; #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),TRUE) /* Find the address one past the end of SEC. */ #define bfd_get_section_limit(bfd, sec) \ - (((sec)->rawsize ? (sec)->rawsize : (sec)->size) \ - / bfd_octets_per_byte (bfd)) + (((bfd)->direction != write_direction && (sec)->rawsize != 0 \ + ? (sec)->rawsize : (sec)->size) / bfd_octets_per_byte (bfd)) /* Return TRUE if input section SEC has been discarded. */ #define elf_discarded_section(sec) \ diff --git a/bfd/compress.c b/bfd/compress.c index 669033c..a82a8bc 100644 --- a/bfd/compress.c +++ b/bfd/compress.c @@ -1,5 +1,5 @@ /* Compressed section support (intended for debug sections). - Copyright 2008, 2010 + Copyright 2008, 2010, 2011 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -158,7 +158,7 @@ DESCRIPTION bfd_boolean bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr) { - bfd_size_type sz = sec->rawsize ? sec->rawsize : sec->size; + bfd_size_type sz; bfd_byte *p = *ptr; #ifdef HAVE_ZLIB_H bfd_boolean ret; @@ -169,6 +169,10 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr) bfd_byte *uncompressed_buffer; #endif + if (abfd->direction != write_direction && sec->rawsize != 0) + sz = sec->rawsize; + else + sz = sec->size; if (sz == 0) return TRUE; diff --git a/bfd/elf32-microblaze.c b/bfd/elf32-microblaze.c index f32e06e..2d460ab 100644 --- a/bfd/elf32-microblaze.c +++ b/bfd/elf32-microblaze.c @@ -1,6 +1,6 @@ /* Xilinx MicroBlaze-specific support for 32-bit ELF - Copyright 2009, 2010 Free Software Foundation, Inc. + Copyright 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -824,7 +824,7 @@ microblaze_elf_relocate_section (bfd *output_bfd, } /* Sanity check the address. */ - if (offset > bfd_get_section_limit (output_bfd, input_section)) + if (offset > bfd_get_section_limit (input_bfd, input_section)) { r = bfd_reloc_outofrange; goto check_reloc; diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c index 0a5e12c..55f2eaa 100644 --- a/bfd/elf32-rx.c +++ b/bfd/elf32-rx.c @@ -1,5 +1,5 @@ /* Renesas RX specific support for 32-bit ELF. - Copyright (C) 2008, 2009, 2010 + Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -3305,13 +3305,12 @@ rx_final_link (bfd * abfd, struct bfd_link_info * info) #endif if (o->flags & SEC_CODE && bfd_big_endian (abfd) - && (o->size % 4 || o->rawsize % 4)) + && o->size % 4) { #ifdef DJDEBUG fprintf (stderr, "adjusting...\n"); #endif o->size += 4 - (o->size % 4); - o->rawsize += 4 - (o->rawsize % 4); } } diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index bd73d28..ca0a3bc 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -1,6 +1,6 @@ /* IA-64 support for 64-bit ELF Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010 Free Software Foundation, Inc. + 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Contributed by David Mosberger-Tang <davidm@hpl.hp.com> This file is part of BFD, the Binary File Descriptor library. @@ -215,7 +215,7 @@ static bfd_boolean elfNN_ia64_dynamic_symbol_p static bfd_reloc_status_type elfNN_ia64_install_value (bfd_byte *hit_addr, bfd_vma val, unsigned int r_type); static bfd_boolean elfNN_ia64_choose_gp - (bfd *abfd, struct bfd_link_info *info); + (bfd *abfd, struct bfd_link_info *info, bfd_boolean final); static void elfNN_ia64_relax_ldxmov (bfd_byte *contents, bfd_vma off); static void elfNN_ia64_dyn_sym_traverse @@ -1221,7 +1221,7 @@ elfNN_ia64_relax_section (bfd *abfd, asection *sec, gp = _bfd_get_gp_value (obfd); if (gp == 0) { - if (!elfNN_ia64_choose_gp (obfd, link_info)) + if (!elfNN_ia64_choose_gp (obfd, link_info, FALSE)) goto error_return; gp = _bfd_get_gp_value (obfd); } @@ -4298,7 +4298,7 @@ elfNN_ia64_unwind_entry_compare (const PTR a, const PTR b) /* Make sure we've got ourselves a nice fat __gp value. */ static bfd_boolean -elfNN_ia64_choose_gp (bfd *abfd, struct bfd_link_info *info) +elfNN_ia64_choose_gp (bfd *abfd, struct bfd_link_info *info, bfd_boolean final) { bfd_vma min_vma = (bfd_vma) -1, max_vma = 0; bfd_vma min_short_vma = min_vma, max_short_vma = 0; @@ -4321,7 +4321,12 @@ elfNN_ia64_choose_gp (bfd *abfd, struct bfd_link_info *info) continue; lo = os->vma; - hi = os->vma + (os->rawsize ? os->rawsize : os->size); + /* When this function is called from elfNN_ia64_final_link + the correct value to use is os->size. When called from + elfNN_ia64_relax_section we are in the middle of section + sizing; some sections will already have os->size set, others + will have os->size zero and os->rawsize the previous size. */ + hi = os->vma + (!final && os->rawsize ? os->rawsize : os->size); if (hi < lo) hi = (bfd_vma) -1; @@ -4462,7 +4467,7 @@ elfNN_ia64_final_link (bfd *abfd, struct bfd_link_info *info) /* We assume after gp is set, section size will only decrease. We need to adjust gp for it. */ _bfd_set_gp_value (abfd, 0); - if (! elfNN_ia64_choose_gp (abfd, info)) + if (! elfNN_ia64_choose_gp (abfd, info, TRUE)) return FALSE; gp_val = _bfd_get_gp_value (abfd); diff --git a/bfd/libbfd.c b/bfd/libbfd.c index 8b24378..4e5813a 100644 --- a/bfd/libbfd.c +++ b/bfd/libbfd.c @@ -866,7 +866,15 @@ _bfd_generic_get_section_contents (bfd *abfd, return FALSE; } - sz = section->rawsize ? section->rawsize : section->size; + /* We do allow reading of a section after bfd_final_link has + written the contents out to disk. In that situation, rawsize is + just a stale version of size, so ignore it. Otherwise we must be + reading an input section, where rawsize, if different to size, + is the on-disk size. */ + if (abfd->direction != write_direction && section->rawsize != 0) + sz = section->rawsize; + else + sz = section->size; if (offset + count < count || offset + count > sz) { @@ -919,7 +927,10 @@ _bfd_generic_get_section_contents_in_window w->data = w->i->data; return bfd_get_section_contents (abfd, section, w->data, offset, count); } - sz = section->rawsize ? section->rawsize : section->size; + if (abfd->direction != write_direction && section->rawsize != 0) + sz = section->rawsize; + else + sz = section->size; if (offset + count > sz || ! bfd_get_file_window (abfd, section->filepos + offset, count, w, TRUE)) diff --git a/bfd/section.c b/bfd/section.c index bff8adf..65ac5e6 100644 --- a/bfd/section.c +++ b/bfd/section.c @@ -1,6 +1,6 @@ /* Object file "section" support for the BFD library. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 + 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Written by Cygnus Support. @@ -1456,7 +1456,10 @@ bfd_get_section_contents (bfd *abfd, return TRUE; } - sz = section->rawsize ? section->rawsize : section->size; + if (abfd->direction != write_direction && section->rawsize != 0) + sz = section->rawsize; + else + sz = section->size; if ((bfd_size_type) offset > sz || count > sz || offset + count > sz |