diff options
author | Alan Modra <amodra@gmail.com> | 2020-12-16 00:42:21 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2020-12-16 15:17:53 +1030 |
commit | c410035d37d8237c641155c4e51e7ccf53decb29 (patch) | |
tree | f61182fd4ba33baefa14ea1cbe197dfb05d9204b /gas | |
parent | 3f75e1d67fe871db85d46618b95d0dc92291577d (diff) | |
download | gdb-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 'gas')
-rw-r--r-- | gas/ChangeLog | 5 | ||||
-rw-r--r-- | gas/config/obj-elf.c | 27 |
2 files changed, 16 insertions, 16 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index 1a6c85a..2816395 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2020-12-16 Alan Modra <amodra@gmail.com> + + * config/obj-elf.c (obj_elf_section): Don't set elf_osabi here. + (obj_elf_type): Likewise. + 2020-12-15 Alan Modra <amodra@gmail.com> PR 27071 diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index bee95c3..d030b54 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -1425,13 +1425,13 @@ obj_elf_section (int push) if ((gnu_attr & (SHF_GNU_MBIND | SHF_GNU_RETAIN)) != 0) { - struct elf_backend_data *bed; + const struct elf_backend_data *bed; bfd_boolean mbind_p = (gnu_attr & SHF_GNU_MBIND) != 0; if (mbind_p && (attr & SHF_ALLOC) == 0) as_bad (_("SHF_ALLOC isn't set for GNU_MBIND section: %s"), name); - bed = (struct elf_backend_data *) get_elf_backend_data (stdoutput); + bed = get_elf_backend_data (stdoutput); if (bed->elf_osabi != ELFOSABI_GNU && bed->elf_osabi != ELFOSABI_FREEBSD @@ -1440,9 +1440,6 @@ obj_elf_section (int push) mbind_p ? "GNU_MBIND" : "GNU_RETAIN"); else { - if (bed->elf_osabi == ELFOSABI_NONE) - bed->elf_osabi = ELFOSABI_GNU; - if (mbind_p) elf_tdata (stdoutput)->has_gnu_osabi |= elf_gnu_osabi_mbind; if ((gnu_attr & SHF_GNU_RETAIN) != 0) @@ -2361,13 +2358,12 @@ obj_elf_type (int ignore ATTRIBUTE_UNUSED) || strcmp (type_name, "10") == 0 || strcmp (type_name, "STT_GNU_IFUNC") == 0) { - struct elf_backend_data *bed; + const struct elf_backend_data *bed; - bed = (struct elf_backend_data *) get_elf_backend_data (stdoutput); - if (bed->elf_osabi == ELFOSABI_NONE) - bed->elf_osabi = ELFOSABI_GNU; - else if (bed->elf_osabi != ELFOSABI_GNU - && bed->elf_osabi != ELFOSABI_FREEBSD) + bed = get_elf_backend_data (stdoutput); + if (bed->elf_osabi != ELFOSABI_NONE + && bed->elf_osabi != ELFOSABI_GNU + && bed->elf_osabi != ELFOSABI_FREEBSD) as_bad (_("symbol type \"%s\" is supported only by GNU " "and FreeBSD targets"), type_name); /* MIPS targets do not support IFUNCS. */ @@ -2379,12 +2375,11 @@ obj_elf_type (int ignore ATTRIBUTE_UNUSED) } else if (strcmp (type_name, "gnu_unique_object") == 0) { - struct elf_backend_data *bed; + const struct elf_backend_data *bed; - bed = (struct elf_backend_data *) get_elf_backend_data (stdoutput); - if (bed->elf_osabi == ELFOSABI_NONE) - bed->elf_osabi = ELFOSABI_GNU; - else if (bed->elf_osabi != ELFOSABI_GNU) + bed = get_elf_backend_data (stdoutput); + if (bed->elf_osabi != ELFOSABI_NONE + && bed->elf_osabi != ELFOSABI_GNU) as_bad (_("symbol type \"%s\" is supported only by GNU targets"), type_name); elf_tdata (stdoutput)->has_gnu_osabi |= elf_gnu_osabi_unique; |