aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog34
-rw-r--r--bfd/bfd-in2.h8
-rw-r--r--bfd/bfd.c127
-rw-r--r--bfd/elf-bfd.h8
-rw-r--r--bfd/elf32-arm.c3
-rw-r--r--bfd/elf32-mips.c1
-rw-r--r--bfd/elf32-ppc.c1
-rw-r--r--bfd/elf32-sh.c3
-rw-r--r--bfd/elf32-sh64.c3
-rw-r--r--bfd/elf32-sparc.c1
-rw-r--r--bfd/elf64-alpha.c1
-rw-r--r--bfd/elf64-ppc.c1
-rw-r--r--bfd/elf64-sparc.c1
-rw-r--r--bfd/elf64-x86-64.c1
-rw-r--r--bfd/elfn32-mips.c1
-rw-r--r--bfd/elfxx-ia64.c2
-rw-r--r--bfd/elfxx-target.h7
-rw-r--r--bfd/targets.c35
18 files changed, 221 insertions, 17 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 65de90e..075bbc3 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,37 @@
+2006-05-30 H.J. Lu <hongjiu.lu@intel.com>
+
+ * bfd.c (bfd_emul_get_maxpagesize): New.
+ (bfd_elf_set_pagesize): Likewise.
+ (bfd_emul_set_maxpagesize): Likewise.
+ (bfd_emul_get_commonpagesize): Likewise.
+ (bfd_emul_set_commonpagesize): Likewise.
+ * bfd-in2.h: Regenerated.
+
+ * elf-bfd.h (elf_backend_data): Add commonpagesize.
+ (xvec_get_elf_backend_data): New.
+ (get_elf_backend_data): Use xvec_get_elf_backend_data.
+
+ * elf32-arm.c (elf32_arm_vxworks_bed): Remove const.
+ * elfxx-target.h (elfNN_bed): Likewise.
+
+ * elf32-arm.c (ELF_COMMONPAGESIZE): Defined.
+ * elf32-mips.c (ELF_COMMONPAGESIZE): Likewise.
+ * elf32-ppc.c (ELF_COMMONPAGESIZE): Likewise.
+ * elf32-sh.c (ELF_COMMONPAGESIZE): Likewise.
+ * elf32-sh64.c (ELF_COMMONPAGESIZE): Likewise.
+ * elf32-sparc.c (ELF_COMMONPAGESIZE): Likewise.
+ * elf64-alpha.c (ELF_COMMONPAGESIZE): Likewise.
+ * elf64-ppc.c (ELF_COMMONPAGESIZE): Likewise.
+ * elf64-sparc.c (ELF_COMMONPAGESIZE): Likewise.
+ * elf64-x86-64.c (ELF_COMMONPAGESIZE): Likewise.
+ * elfn32-mips.c (ELF_COMMONPAGESIZE): Likewise.
+ * elfxx-ia64.c (ELF_COMMONPAGESIZE): Likewise.
+
+ * elfxx-target.h (ELF_COMMONPAGESIZE): Define if not defined.
+ (elfNN_bed): Initialize commonpagesize with ELF_COMMONPAGESIZE.
+
+ * targets.c (bfd_find_target): Support NULL abfd.
+
2006-05-30 Nick Clifton <nickc@redhat.com>
* po/es.po: Updated Spanish translation.
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index cdbeb58..b896a6b 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -4709,6 +4709,14 @@ void bfd_preserve_restore (bfd *, struct bfd_preserve *);
void bfd_preserve_finish (bfd *, struct bfd_preserve *);
+bfd_vma bfd_emul_get_maxpagesize (const char *);
+
+void bfd_emul_set_maxpagesize (const char *, bfd_vma);
+
+bfd_vma bfd_emul_get_commonpagesize (const char *);
+
+void bfd_emul_set_commonpagesize (const char *, bfd_vma);
+
/* Extracted from archive.c. */
symindex bfd_get_next_mapent
(bfd *abfd, symindex previous, carsym **sym);
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 733f6ee..ebfd314 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1513,3 +1513,130 @@ bfd_preserve_finish (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_preserve *preserve)
objalloc. */
bfd_hash_table_free (&preserve->section_htab);
}
+
+/*
+FUNCTION
+ bfd_emul_get_maxpagesize
+
+SYNOPSIS
+ bfd_vma bfd_emul_get_maxpagesize (const char *);
+
+DESCRIPTION
+ Returns the maximum page size, in bytes, as determined by
+ emulation.
+
+RETURNS
+ Returns the maximum page size in bytes for ELF, abort
+ otherwise.
+*/
+
+bfd_vma
+bfd_emul_get_maxpagesize (const char *emul)
+{
+ const bfd_target *target;
+
+ target = bfd_find_target (emul, NULL);
+ if (target != NULL
+ && target->flavour == bfd_target_elf_flavour)
+ return xvec_get_elf_backend_data (target)->maxpagesize;
+
+ abort ();
+ return 0;
+}
+
+static void
+bfd_elf_set_pagesize (const bfd_target *target, bfd_vma size,
+ int offset, const bfd_target *orig_target)
+{
+ if (target->flavour == bfd_target_elf_flavour)
+ {
+ const struct elf_backend_data *bed;
+
+ bed = xvec_get_elf_backend_data (target);
+ *((bfd_vma *) ((char *) bed + offset)) = size;
+ }
+
+ if (target->alternative_target
+ && target->alternative_target != orig_target)
+ bfd_elf_set_pagesize (target->alternative_target, size, offset,
+ orig_target);
+}
+
+/*
+FUNCTION
+ bfd_emul_set_maxpagesize
+
+SYNOPSIS
+ void bfd_emul_set_maxpagesize (const char *, bfd_vma);
+
+DESCRIPTION
+ For ELF, set the maximum page size for the emulation. It is
+ a no-op for other formats.
+
+*/
+
+void
+bfd_emul_set_maxpagesize (const char *emul, bfd_vma size)
+{
+ const bfd_target *target;
+
+ target = bfd_find_target (emul, NULL);
+ if (target)
+ bfd_elf_set_pagesize (target, size,
+ offsetof (struct elf_backend_data,
+ maxpagesize), target);
+}
+
+/*
+FUNCTION
+ bfd_emul_get_commonpagesize
+
+SYNOPSIS
+ bfd_vma bfd_emul_get_commonpagesize (const char *);
+
+DESCRIPTION
+ Returns the common page size, in bytes, as determined by
+ emulation.
+
+RETURNS
+ Returns the common page size in bytes for ELF, abort otherwise.
+*/
+
+bfd_vma
+bfd_emul_get_commonpagesize (const char *emul)
+{
+ const bfd_target *target;
+
+ target = bfd_find_target (emul, NULL);
+ if (target != NULL
+ && target->flavour == bfd_target_elf_flavour)
+ return xvec_get_elf_backend_data (target)->commonpagesize;
+
+ abort ();
+ return 0;
+}
+
+/*
+FUNCTION
+ bfd_emul_set_commonpagesize
+
+SYNOPSIS
+ void bfd_emul_set_commonpagesize (const char *, bfd_vma);
+
+DESCRIPTION
+ For ELF, set the common page size for the emulation. It is
+ a no-op for other formats.
+
+*/
+
+void
+bfd_emul_set_commonpagesize (const char *emul, bfd_vma size)
+{
+ const bfd_target *target;
+
+ target = bfd_find_target (emul, NULL);
+ if (target)
+ bfd_elf_set_pagesize (target, size,
+ offsetof (struct elf_backend_data,
+ commonpagesize), target);
+}
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 3a32fc4..89baa9c 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -571,6 +571,9 @@ struct elf_backend_data
pages at least this large. May be smaller than maxpagesize. */
bfd_vma minpagesize;
+ /* The common page size for this backend. */
+ bfd_vma commonpagesize;
+
/* The BFD flags applied to sections created for dynamic linking. */
flagword dynamic_sec_flags;
@@ -1196,8 +1199,11 @@ struct bfd_elf_section_data
&& (sec)->sec_info_type != ELF_INFO_TYPE_MERGE \
&& (sec)->sec_info_type != ELF_INFO_TYPE_JUST_SYMS)
+#define xvec_get_elf_backend_data(xvec) \
+ ((struct elf_backend_data *) (xvec)->backend_data)
+
#define get_elf_backend_data(abfd) \
- ((const struct elf_backend_data *) (abfd)->xvec->backend_data)
+ xvec_get_elf_backend_data ((abfd)->xvec)
/* This struct is used to pass information to routines called via
elf_link_hash_traverse which must return failure. */
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index e2beac7..ae8ef8f 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -62,7 +62,7 @@
#define ARM_ELF_ABI_VERSION 0
#define ARM_ELF_OS_ABI_VERSION ELFOSABI_ARM
-static const struct elf_backend_data elf32_arm_vxworks_bed;
+static struct elf_backend_data elf32_arm_vxworks_bed;
/* Note: code such as elf32_arm_reloc_type_lookup expect to use e.g.
R_ARM_PC24 as an index into this, and find the R_ARM_PC24 HOWTO
@@ -8406,6 +8406,7 @@ const struct elf_size_info elf32_arm_size_info = {
#define ELF_MAXPAGESIZE 0x8000
#endif
#define ELF_MINPAGESIZE 0x1000
+#define ELF_COMMONPAGESIZE 0x1000
#define bfd_elf32_mkobject elf32_arm_mkobject
diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c
index 6ed4ad3..fd8a427 100644
--- a/bfd/elf32-mips.c
+++ b/bfd/elf32-mips.c
@@ -1599,6 +1599,7 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
/* The SVR4 MIPS ABI says that this should be 0x10000, but Irix 5 uses
a value of 0x1000, and we are compatible. */
#define ELF_MAXPAGESIZE 0x1000
+#define ELF_COMMONPAGESIZE 0x1000
#include "elf32-target.h"
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 9be70f8..b1d18e7 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -7436,6 +7436,7 @@ ppc_elf_finish_dynamic_sections (bfd *output_bfd,
#define ELF_MAXPAGESIZE 0x10000
#endif
#define ELF_MINPAGESIZE 0x1000
+#define ELF_COMMONPAGESIZE 0x1000
#define elf_info_to_howto ppc_elf_info_to_howto
#ifdef EM_CYGNUS_POWERPC
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index 118690d..cf59095 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -7371,6 +7371,7 @@ sh_elf_plt_sym_val (bfd_vma i, const asection *plt,
#define TARGET_LITTLE_NAME "elf32-shl-nbsd"
#undef ELF_MAXPAGESIZE
#define ELF_MAXPAGESIZE 0x10000
+#undef ELF_COMMONPAGESIZE
#undef elf_symbol_leading_char
#define elf_symbol_leading_char 0
#undef elf32_bed
@@ -7388,6 +7389,8 @@ sh_elf_plt_sym_val (bfd_vma i, const asection *plt,
#define TARGET_LITTLE_SYM bfd_elf32_shlin_vec
#undef TARGET_LITTLE_NAME
#define TARGET_LITTLE_NAME "elf32-sh-linux"
+#undef ELF_COMMONPAGESIZE
+#define ELF_COMMONPAGESIZE 0x1000
#undef elf_backend_grok_prstatus
#define elf_backend_grok_prstatus elf32_shlin_grok_prstatus
diff --git a/bfd/elf32-sh64.c b/bfd/elf32-sh64.c
index 219f753..55aa25b 100644
--- a/bfd/elf32-sh64.c
+++ b/bfd/elf32-sh64.c
@@ -785,6 +785,7 @@ static const struct bfd_elf_special_section sh64_elf_special_sections[] =
#define TARGET_LITTLE_NAME "elf32-sh64l-nbsd"
#undef ELF_MAXPAGESIZE
#define ELF_MAXPAGESIZE 0x10000
+#undef ELF_COMMONPAGESIZE
#undef elf_symbol_leading_char
#define elf_symbol_leading_char 0
#undef elf32_bed
@@ -803,6 +804,8 @@ static const struct bfd_elf_special_section sh64_elf_special_sections[] =
#define TARGET_LITTLE_NAME "elf32-sh64-linux"
#undef elf32_bed
#define elf32_bed elf32_sh64_lin_bed
+#undef ELF_COMMONPAGESIZE
+#define ELF_COMMONPAGESIZE 0x1000
#include "elf32-target.h"
diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c
index 3bfb38a..3f0c7d6 100644
--- a/bfd/elf32-sparc.c
+++ b/bfd/elf32-sparc.c
@@ -172,6 +172,7 @@ elf32_sparc_reloc_type_class (const Elf_Internal_Rela *rela)
#define ELF_MACHINE_CODE EM_SPARC
#define ELF_MACHINE_ALT1 EM_SPARC32PLUS
#define ELF_MAXPAGESIZE 0x10000
+#define ELF_COMMONPAGESIZE 0x2000
#define bfd_elf32_bfd_merge_private_bfd_data \
elf32_sparc_merge_private_bfd_data
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 76d0661..625d834 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -5231,6 +5231,7 @@ static const struct elf_size_info alpha_elf_size_info =
#define ELF_ARCH bfd_arch_alpha
#define ELF_MACHINE_CODE EM_ALPHA
#define ELF_MAXPAGESIZE 0x10000
+#define ELF_COMMONPAGESIZE 0x2000
#define bfd_elf64_bfd_link_hash_table_create \
elf64_alpha_bfd_link_hash_table_create
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index b1ec942..2c29b57 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -61,6 +61,7 @@ static bfd_vma opd_entry_value
#define ELF_ARCH bfd_arch_powerpc
#define ELF_MACHINE_CODE EM_PPC64
#define ELF_MAXPAGESIZE 0x10000
+#define ELF_COMMONPAGESIZE 0x1000
#define elf_info_to_howto ppc64_elf_info_to_howto
#define elf_backend_want_got_sym 0
diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c
index dd1c302..5c928e2 100644
--- a/bfd/elf64-sparc.c
+++ b/bfd/elf64-sparc.c
@@ -814,6 +814,7 @@ const struct elf_size_info elf64_sparc_size_info =
#define TARGET_BIG_NAME "elf64-sparc"
#define ELF_ARCH bfd_arch_sparc
#define ELF_MAXPAGESIZE 0x100000
+#define ELF_COMMONPAGESIZE 0x2000
/* This is the official ABI value. */
#define ELF_MACHINE_CODE EM_SPARCV9
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 7799a43..42569b7 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -3632,6 +3632,7 @@ static const struct bfd_elf_special_section
#define ELF_MACHINE_CODE EM_X86_64
#define ELF_MAXPAGESIZE 0x200000
#define ELF_MINPAGESIZE 0x1000
+#define ELF_COMMONPAGESIZE 0x1000
#define elf_backend_can_gc_sections 1
#define elf_backend_can_refcount 1
diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c
index b1211f0..8e7eb53 100644
--- a/bfd/elfn32-mips.c
+++ b/bfd/elfn32-mips.c
@@ -2384,6 +2384,7 @@ static const struct ecoff_debug_swap mips_elf32_ecoff_debug_swap = {
a value of 0x1000, and we are compatible.
FIXME: How does this affect NewABI? */
#define ELF_MAXPAGESIZE 0x1000
+#define ELF_COMMONPAGESIZE 0x1000
#include "elf32-target.h"
diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c
index 953a776..817ccb1 100644
--- a/bfd/elfxx-ia64.c
+++ b/bfd/elfxx-ia64.c
@@ -5717,6 +5717,7 @@ elfNN_hpux_backend_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED,
#define ELF_MACHINE_ALT1 1999 /* EAS2.3 */
#define ELF_MACHINE_ALT2 1998 /* EAS2.2 */
#define ELF_MAXPAGESIZE 0x10000 /* 64KB */
+#define ELF_COMMONPAGESIZE 0x4000 /* 16KB */
#define elf_backend_section_from_shdr \
elfNN_ia64_section_from_shdr
@@ -5824,6 +5825,7 @@ elfNN_hpux_backend_symbol_processing (bfd *abfd ATTRIBUTE_UNUSED,
#undef ELF_MAXPAGESIZE
#define ELF_MAXPAGESIZE 0x1000 /* 4K */
+#undef ELF_COMMONPAGESIZE
#undef elfNN_bed
#define elfNN_bed elfNN_ia64_hpux_bed
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index 5a5ca34..fad00f2 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -294,6 +294,10 @@
#define ELF_MINPAGESIZE ELF_MAXPAGESIZE
#endif
+#ifndef ELF_COMMONPAGESIZE
+#define ELF_COMMONPAGESIZE ELF_MAXPAGESIZE
+#endif
+
#ifndef ELF_DYNAMIC_SEC_FLAGS
/* Note that we set the SEC_IN_MEMORY flag for these sections. */
#define ELF_DYNAMIC_SEC_FLAGS \
@@ -559,12 +563,13 @@
extern const struct elf_size_info _bfd_elfNN_size_info;
#ifndef INCLUDED_TARGET_FILE
-static const struct elf_backend_data elfNN_bed =
+static struct elf_backend_data elfNN_bed =
{
ELF_ARCH, /* arch */
ELF_MACHINE_CODE, /* elf_machine_code */
ELF_MAXPAGESIZE, /* maxpagesize */
ELF_MINPAGESIZE, /* minpagesize */
+ ELF_COMMONPAGESIZE, /* commonpagesize */
ELF_DYNAMIC_SEC_FLAGS, /* dynamic_sec_flags */
elf_info_to_howto,
elf_info_to_howto_rel,
diff --git a/bfd/targets.c b/bfd/targets.c
index 849eb94..09e4bc0 100644
--- a/bfd/targets.c
+++ b/bfd/targets.c
@@ -1307,14 +1307,15 @@ SYNOPSIS
DESCRIPTION
Return a pointer to the transfer vector for the object target
- named @var{target_name}. If @var{target_name} is <<NULL>>, choose the
- one in the environment variable <<GNUTARGET>>; if that is null or not
- defined, then choose the first entry in the target list.
- Passing in the string "default" or setting the environment
- variable to "default" will cause the first entry in the target
- list to be returned, and "target_defaulted" will be set in the
- BFD. This causes <<bfd_check_format>> to loop over all the
- targets to find the one that matches the file being read.
+ named @var{target_name}. If @var{target_name} is <<NULL>>,
+ choose the one in the environment variable <<GNUTARGET>>; if
+ that is null or not defined, then choose the first entry in the
+ target list. Passing in the string "default" or setting the
+ environment variable to "default" will cause the first entry in
+ the target list to be returned, and "target_defaulted" will be
+ set in the BFD if @var{abfd} isn't <<NULL>>. This causes
+ <<bfd_check_format>> to loop over all the targets to find the
+ one that matches the file being read.
*/
const bfd_target *
@@ -1331,21 +1332,27 @@ bfd_find_target (const char *target_name, bfd *abfd)
/* This is safe; the vector cannot be null. */
if (targname == NULL || strcmp (targname, "default") == 0)
{
- abfd->target_defaulted = TRUE;
if (bfd_default_vector[0] != NULL)
- abfd->xvec = bfd_default_vector[0];
+ target = bfd_default_vector[0];
else
- abfd->xvec = bfd_target_vector[0];
- return abfd->xvec;
+ target = bfd_target_vector[0];
+ if (abfd)
+ {
+ abfd->xvec = target;
+ abfd->target_defaulted = TRUE;
+ }
+ return target;
}
- abfd->target_defaulted = FALSE;
+ if (abfd)
+ abfd->target_defaulted = FALSE;
target = find_target (targname);
if (target == NULL)
return NULL;
- abfd->xvec = target;
+ if (abfd)
+ abfd->xvec = target;
return target;
}