aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-12-16 00:42:21 +1030
committerAlan Modra <amodra@gmail.com>2020-12-16 15:17:53 +1030
commitc410035d37d8237c641155c4e51e7ccf53decb29 (patch)
treef61182fd4ba33baefa14ea1cbe197dfb05d9204b /ld
parent3f75e1d67fe871db85d46618b95d0dc92291577d (diff)
downloadgdb-c410035d37d8237c641155c4e51e7ccf53decb29.zip
gdb-c410035d37d8237c641155c4e51e7ccf53decb29.tar.gz
gdb-c410035d37d8237c641155c4e51e7ccf53decb29.tar.bz2
constify elfNN_bed
elfNN_bed was made writable as an expedient means of communicating ld -z max-page-size and ld -z common-page-size values to BFD linker code, and even for objcopy to communicate segment alignment between copy_private_bfd_data, rewrite_elf_program_header and assign_file_positions_for_load_sections. Some time later elfNN_bed elf_osabi was written by gas. It turns out none of these modifications to elfNN_bed was necessary, so make it const again. include/ * bfdlink.h (struct bfd_link_info): Add maxpagesize and commonpagesize. bfd/ * elfxx-target.h (elfNN_bed): Constify. * bfd.c (bfd_elf_set_pagesize): Delete. (bfd_emul_set_maxpagesize, bfd_emul_set_commonpagesize): Delete. * elf.c (get_program_header_size): Get commonpagesize from link info. (_bfd_elf_map_sections_to_segments): Get maxpagesize from link info. (assign_file_positions_for_load_sections): Likewise. (assign_file_positions_for_non_load_sections): Likewise. (rewrite_elf_program_header): Add maxpagesize param. Set map_p_align. (copy_private_bfd_data): Don't call bfd_elf_set_maxpagesize. Instead pass maxpagesize to rewrite_elf_program_header. * elf32-nds32.c (relax_range_measurement): Add link_info param. Get maxpagesize from link_info. Adjust caller. * bfd-in2.h: Regenerate. gas/ * config/obj-elf.c (obj_elf_section): Don't set elf_osabi here. (obj_elf_type): Likewise. ld/ * ld.h (ld_config_type): Delete maxpagesize and commonpagesize. * emultempl/elf.em: Use link_info rather than config for maxpagesize and commonpagesize. * emultempl/ppc32elf.em: Likewise. * ldexp.c (fold_binary, fold_name): Likewise. * ldemul.c (after_parse_default): Likewise. (set_output_arch_default): Don't call bfd_emul_set_maxpagesize or bfd_emul_set_commonpagesize.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog11
-rw-r--r--ld/emultempl/elf.em9
-rw-r--r--ld/emultempl/ppc32elf.em2
-rw-r--r--ld/ld.h6
-rw-r--r--ld/ldemul.c13
-rw-r--r--ld/ldexp.c8
6 files changed, 26 insertions, 23 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 9a0ff59..46acbd9 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,14 @@
+2020-12-16 Alan Modra <amodra@gmail.com>
+
+ * ld.h (ld_config_type): Delete maxpagesize and commonpagesize.
+ * emultempl/elf.em: Use link_info rather than config
+ for maxpagesize and commonpagesize.
+ * emultempl/ppc32elf.em: Likewise.
+ * ldexp.c (fold_binary, fold_name): Likewise.
+ * ldemul.c (after_parse_default): Likewise.
+ (set_output_arch_default): Don't call bfd_emul_set_maxpagesize
+ or bfd_emul_set_commonpagesize.
+
2020-12-15 Vivek Das Mohapatra <vivek@collabora.com>
* emultempl/elf.em (gld${EMULATION_NAME}_handle_option):
diff --git a/ld/emultempl/elf.em b/ld/emultempl/elf.em
index aa40c78..b915ad5 100644
--- a/ld/emultempl/elf.em
+++ b/ld/emultempl/elf.em
@@ -716,17 +716,18 @@ fragment <<EOF
{
char *end;
- config.maxpagesize = strtoul (optarg + 14, &end, 0);
- if (*end || (config.maxpagesize & (config.maxpagesize - 1)) != 0)
+ link_info.maxpagesize = strtoul (optarg + 14, &end, 0);
+ if (*end
+ || (link_info.maxpagesize & (link_info.maxpagesize - 1)) != 0)
einfo (_("%F%P: invalid maximum page size \`%s'\n"),
optarg + 14);
}
else if (CONST_STRNEQ (optarg, "common-page-size="))
{
char *end;
- config.commonpagesize = strtoul (optarg + 17, &end, 0);
+ link_info.commonpagesize = strtoul (optarg + 17, &end, 0);
if (*end
- || (config.commonpagesize & (config.commonpagesize - 1)) != 0)
+ || (link_info.commonpagesize & (link_info.commonpagesize - 1)) != 0)
einfo (_("%F%P: invalid common page size \`%s'\n"),
optarg + 17);
}
diff --git a/ld/emultempl/ppc32elf.em b/ld/emultempl/ppc32elf.em
index 0402ffb..9d8e933 100644
--- a/ld/emultempl/ppc32elf.em
+++ b/ld/emultempl/ppc32elf.em
@@ -51,7 +51,7 @@ ppc_after_open_output (void)
params.emit_stub_syms = (link_info.emitrelocations
|| bfd_link_pic (&link_info));
if (params.pagesize == 0)
- params.pagesize = config.commonpagesize;
+ params.pagesize = link_info.commonpagesize;
ppc_elf_link_params (&link_info, &params);
}
diff --git a/ld/ld.h b/ld/ld.h
index 7f7d716..612d530 100644
--- a/ld/ld.h
+++ b/ld/ld.h
@@ -294,12 +294,6 @@ typedef struct
/* The size of the hash table to use. */
unsigned long hash_table_size;
- /* The maximum page size for ELF. */
- bfd_vma maxpagesize;
-
- /* The common page size for ELF. */
- bfd_vma commonpagesize;
-
/* If set, print discarded sections in map file output. */
bfd_boolean print_map_discarded;
diff --git a/ld/ldemul.c b/ld/ldemul.c
index 920afc8..fc51493 100644
--- a/ld/ldemul.c
+++ b/ld/ldemul.c
@@ -232,11 +232,11 @@ after_parse_default (void)
if (!is_vma)
ldlang_add_undef (entry_symbol.name, entry_from_cmdline);
}
- if (config.maxpagesize == 0)
- config.maxpagesize = bfd_emul_get_maxpagesize (default_target);
- if (config.commonpagesize == 0)
- config.commonpagesize = bfd_emul_get_commonpagesize (default_target,
- link_info.relro);
+ if (link_info.maxpagesize == 0)
+ link_info.maxpagesize = bfd_emul_get_maxpagesize (default_target);
+ if (link_info.commonpagesize == 0)
+ link_info.commonpagesize = bfd_emul_get_commonpagesize (default_target,
+ link_info.relro);
}
void
@@ -303,9 +303,6 @@ set_output_arch_default (void)
/* Set the output architecture and machine if possible. */
bfd_set_arch_mach (link_info.output_bfd,
ldfile_output_architecture, ldfile_output_machine);
-
- bfd_emul_set_maxpagesize (output_target, config.maxpagesize);
- bfd_emul_set_commonpagesize (output_target, config.commonpagesize);
}
void
diff --git a/ld/ldexp.c b/ld/ldexp.c
index b4e7c41..905055a 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -547,8 +547,8 @@ fold_binary (etree_type *tree)
{
if (!seg->used
&& config.magic_demand_paged
- && config.maxpagesize != 0
- && (seg->value % config.maxpagesize) != 0)
+ && link_info.maxpagesize != 0
+ && (seg->value % link_info.maxpagesize) != 0)
einfo (_("%P: warning: address of `%s' "
"isn't multiple of maximum page size\n"),
segment_name);
@@ -898,9 +898,9 @@ fold_name (etree_type *tree)
case CONSTANT:
if (strcmp (tree->name.name, "MAXPAGESIZE") == 0)
- new_number (config.maxpagesize);
+ new_number (link_info.maxpagesize);
else if (strcmp (tree->name.name, "COMMONPAGESIZE") == 0)
- new_number (config.commonpagesize);
+ new_number (link_info.commonpagesize);
else
einfo (_("%F%P:%pS: unknown constant `%s' referenced in expression\n"),
tree, tree->name.name);