Commit Graph

10 Commits

Author SHA1 Message Date
Alan Modra b3adc24a07 Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
Alan Modra d871d47806 Move elf32.em and elf-generic.em functions
Many ELF linker targets support multiple "emulations" and thus have
multiple copies of elf32.em being compiled and linked into ld.  This
patch moves much of elf32.em and elf-generic.em into files which will
be compiled just once, resulting in a 20% decrease in ld size for
--enable-targets=all.

	* Makefile.am (ALL_EMUL_EXTRA_OFILES): Add ldelf and ldelfgen.
	(CFILES, HFILES, EXTRA_ld_new_SOURCES): Likewise.
	* configure.tgt: Formatting.
	(targ_extra_ofiles): Init to ldelf.o ldelfgen.o, reset to just
	ldelfgen.o for generic ELF targets, and empty for non-ELF.
	* emultempl/aarch64elf.em (gldaarch64_layout_sections_again): Use
	ldelf_map_segments.
	(gld${EMULATION_NAME}_after_allocation): Likewise.
	(real_func, aarch64_for_each_input_file_wrapper),
	(aarch64_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/alphaelf.em (alpha_after_parse): Use ldelf_map_segments.
	* emultempl/armelf.em (gldarm_layout_sections_again): Likewise.
	(gld${EMULATION_NAME}_after_allocation): Likewise.
	(real_func, arm_for_each_input_file_wrapper),
	(arm_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/cr16elf.em (cr16elf_after_parse): Use ldelf_map_segments.
	* emultempl/crxelf.em (crxelf_after_parse): Likewise.  Delete
	declaration.
	* emultempl/cskyelf.em (gldcsky_layout_sections_again): Use
	ldelf_map_segments.
	(gld${EMULATION_NAME}_after_allocation): Likewise.
	(real_func, csky_for_each_input_file_wrapper),
	(csky_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/genelf.em: Include ldelfgen.h.
	(gld${EMULATION_NAME}_before_allocation): Use ldelf_map_segments.
	* emultempl/hppaelf.em (hppaelf_after_parse): Likewise.
	(hppaelf_layout_sections_again): Likewise.
	(gld${EMULATION_NAME}_after_allocation): Likewise.
	(real_func, hppa_for_each_input_file_wrapper),
	(hppa_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/ia64elf.em (ia64elf_after_parse): Use ldelf_map_segments.
	* emultempl/m68hc1xelf.em (real_func),
	(m68hc11_for_each_input_file_wrapper),
	(m68hc11_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/metagelf.em (metagelf_layout_sections_again): Use
	ldelf_map_segments.
	(gld${EMULATION_NAME}_after_allocation): Likewise.
	(real_func, metag_for_each_input_file_wrapper),
	(metag_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/mipself.em (real_func),
	(mips_for_each_input_file_wrapper),
	(mips_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/mmo.em: Don't include elf-bfd.h, do include ldelfgen.h.
	(gld${EMULATION_NAME}_after_allocation): Use ldelf_map_segments.
	* emultempl/nds32elf.em (nds32_elf_after_parse): Use ldelf_after_parse.
	(nds32_elf_after_allocation): Comment fix.
	* emultempl/nios2elf.em (nios2elf_layout_sections_again): Use
	ldelf_map_segments.
	(gld${EMULATION_NAME}_after_allocation): Likewise.
	(real_func, nios2_for_each_input_file_wrapper),
	(nios2_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	* emultempl/ppc32elf.em (gld${EMULATION_NAME}_load_symbols): Delete
	declaration.
	(ppc_recognized_file): Call ldelf_load_symbols.
	* emultempl/ppc64elf.em (ppc_layout_sections_again): Likewise.
	(gld${EMULATION_NAME}_after_allocation): Likewise.
	(real_func, ppc_for_each_input_file_wrapper),
	(ppc_lang_for_each_input_file): Delete.
	(lang_for_each_input_file): Don't define.
	(gld${EMULATION_NAME}_load_symbols): Don't declare.
	(ppc64_recognized_file): Call ldelf_load_symbols.
	* emultempl/riscvelf.em (gld${EMULATION_NAME}_after_allocation):
	Use ldelf_map_segments.
	* emultempl/spuelf.em (spu_place_special_section): Use
	ldelf_place_orphan.
	* emultempl/tic6xdsbt.em (gld${EMULATION_NAME}_after_allocation):
	Use ldelf_map_segments.
	* emultempl/vms.em: Include ldelfgen.h.
	(gld${EMULATION_NAME}_after_allocation): Use ldelf_map_segments.
	* emultempl/elf32.em: Remove unnecessary headers, include ldelf.h
	and ldelfgen.h.  Move much of file content to..
	* ldelf.c: ..here.  New file.
	* ldelf.h: New file.
	* emultempl/elf-generic.em: Move gld${EMULATION_NAME}_map_segments..
	* ldelfgen.c: ..to here.
	* ldelfgen.h: New file.
	* ldlang.c (lang_for_each_input_file): Adjust to only call func
	on real files.
	(lang_for_each_file): Likewise.
	* po/SRC-POTFILES.in: Regenerate.
	* Makefile.in: Regenerate.
2019-09-11 13:44:22 +09:30
Alan Modra 827041555a Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
Andreas Schwab 202d116e57 RISC-V: Don't enable relaxation in relocatable link
PR ld/22949
	* emultempl/riscvelf.em (riscv_elf_before_allocation): Don't
	enable relaxation in relocatable link.
2018-03-15 09:54:51 +01:00
Jim Wilson 770aa8a3d3 RISC-V: Disallow output format changes.
PR 22920
	* emultempl/riscvelf.em (riscv_create_output_section_statements): New.
	(LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS): New.
	* testsuite/ld-elf/pr21884.d (#notarget): Add riscv*-*-*.
	* testsuite/ld-unique/pr21529.d (#notarget): Likewise.
	* testsuite/ld-srec/srec.exp (run_srec_test): For riscv*-*-* target,
	call setup_xfail.
2018-03-06 12:01:50 -08:00
Alan Modra 219d1afa89 Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
Palmer Dabbelt ff6f4d9b2d RISC-V: Add R_RISCV_DELETE, which marks bytes for deletion
We currently delete bytes by shifting an entire BFD backwards to
overwrite the bytes we no longer need.  The result is that relaxing a
BFD is quadratic time.

This patch adds an additional relocation that specifies a byte range
that will be deleted from the final object file, and adds a relaxation
pass (between the existing passes that delete bytes and the alignment
pass) that actually deletes the bytes.  Note that deletion is still
quadratic time, and nothing uses R_RISCV_DELETE yet.

I've been meaning to go convert all the other relaxations to use
R_RISCV_DELETE and then make it faster, but this patch has been sitting
around for months so it looks like that won't happen for a bit.  The
PCREL->GPREL relaxation that comes next uses this, and since we've been
using these two patches out of tree since I wrote them months ago I
figure it's better to just get them in now.  I (or someone else :)) can
convert all the relocations later...

R_RISCV_DELETE will never be emitted into ELF objects, so therefor isn't
exposed to the rest of binutils.  As such, we're not considering this as
part of the ABI.

bfd/ChangeLog

2017-10-19  Palmer Dabbelt  <palmer@dabbelt.com>

        * elfnn-riscv (R_RISCV_DELETE): New define.
        (_bfd_riscv_relax_delete): New function.
        (perform_relocation): Handle R_RISCV_DELETE.
        (_bfd_riscv_relax_section): Likewise.

ld/ChangeLog

2017-10-19  Palmer Dabbelt  <palmer@dabbelt.com>

        * emultempl/riscvelf.em (riscv_elf_before_allocation): Add a
        third relaxation pass.
2017-10-19 09:19:32 -07:00
Alan Modra d003af5580 ld internationalization fixes
* emultempl/aarch64elf.em: Wrap einfo strings in _().  Formatting.
	* emultempl/aix.em: Likewise.
	* emultempl/armcoff.em: Likewise.
	* emultempl/armelf.em: Likewise.
	* emultempl/avrelf.em: Likewise.
	* emultempl/beos.em: Likewise.
	* emultempl/cr16elf.em: Likewise.
	* emultempl/elf-generic.em: Likewise.
	* emultempl/elf32.em: Likewise.
	* emultempl/genelf.em: Likewise.
	* emultempl/hppaelf.em: Likewise.
	* emultempl/linux.em: Likewise.
	* emultempl/lnk960.em: Likewise.
	* emultempl/m68hc1xelf.em: Likewise.
	* emultempl/m68kcoff.em: Likewise.
	* emultempl/m68kelf.em: Likewise.
	* emultempl/metagelf.em: Likewise.
	* emultempl/mipself.em: Likewise.
	* emultempl/mmix-elfnmmo.em: Likewise.
	* emultempl/mmo.em: Likewise.
	* emultempl/msp430.em: Likewise.
	* emultempl/nds32elf.em: Likewise.
	* emultempl/nios2elf.em: Likewise.
	* emultempl/pe.em: Likewise.
	* emultempl/pep.em: Likewise.
	* emultempl/ppc32elf.em: Likewise.
	* emultempl/ppc64elf.em: Likewise.
	* emultempl/riscvelf.em: Likewise.
	* emultempl/s390.em: Likewise.
	* emultempl/scoreelf.em: Likewise.
	* emultempl/spuelf.em: Likewise.
	* emultempl/sunos.em: Likewise.
	* emultempl/tic6xdsbt.em: Likewise.
	* emultempl/v850elf.em: Likewise.
	* emultempl/vms.em: Likewise.
	* emultempl/vxworks.em: Likewise.
	* ldcref.c: Likewise.
	* ldlang.c: Likewise.
	* ldlex.l: Likewise.
	* ldmain.c: Likewise.
	* pe-dll.c: Likewise.
	* plugin.c: Likewise.
2017-10-11 15:04:59 +10:30
Alan Modra 2571583aed Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
Nick Clifton e23eba971d Add support for RISC-V architecture.
bfd	* Makefile.am: Add entries for riscv32-elf and riscv64-elf.
	* config.bdf: Likewise.
	* configure.ac: Likewise.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* archures.c: Add bfd_riscv_arch.
	* reloc.c: Add riscv relocs.
	* targets.c: Add riscv_elf32_vec and riscv_elf64_vec.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* elf-bfd.h: Add RISCV_ELF_DATA to enum elf_target_id.
	* elfnn-riscv.c: New file.
	* elfxx-riscv.c: New file.
	* elfxx-riscv.h: New file.

binutils* readelf.c (guess_is_rela): Add EM_RISCV.
	(get_machine_name): Likewise.
	(dump_relocations): Add support for riscv relocations.
	(get_machine_flags): Add support for riscv flags.
	(is_32bit_abs_reloc): Add R_RISCV_32.
	(is_64bit_abs_reloc): Add R_RISCV_64.
	(is_none_reloc): Add R_RISCV_NONE.
	* testsuite/binutils-all/objdump.exp (cpus_expected): Add riscv.
	Expect the debug_ranges test to fail.

gas	* Makefile.am: Add riscv files.
	* Makefile.in: Regenerate.
	* NEWS: Mention the support for this architecture.
	* configure.in: Define a default architecture.
	* configure: Regenerate.
	* configure.tgt: Add entries for riscv.
	* doc/as.texinfo: Likewise.
	* testsuite/gas/all/gas.exp: Expect the redef tests to fail.
	* testsuite/gas/elf/elf.exp: Expect the groupauto tests to fail.
	* config/tc-riscv.c: New file.
	* config/tc-riscv.h: New file.
	* doc/c-riscv.texi: New file.
	* testsuite/gas/riscv: New directory.
	* testsuite/gas/riscv/riscv.exp: New file.
	* testsuite/gas/riscv/t_insns.d: New file.
	* testsuite/gas/riscv/t_insns.s: New file.

ld	* Makefile.am: Add riscv files.
	* Makefile.in: Regenerate.
	* NEWS: Mention the support for this target.
	* configure.tgt: Add riscv entries.
	* emulparams/elf32lriscv-defs.sh: New file.
	* emulparams/elf32lriscv.sh: New file.
	* emulparams/elf64lriscv-defs.sh: New file.
	* emulparams/elf64lriscv.sh: New file.
	* emultempl/riscvelf.em: New file.

opcodes	* configure.ac: Add entry for bfd_riscv_arch.
	* configure: Regenerate.
	* disassemble.c (disassembler): Add support for riscv.
	(disassembler_usage): Likewise.
	* riscv-dis.c: New file.
	* riscv-opc.c: New file.

include	* dis-asm.h: Add prototypes for print_insn_riscv and
	print_riscv_disassembler_options.
	* elf/riscv.h: New file.
	* opcode/riscv-opc.h: New file.
	* opcode/riscv.h: New file.
2016-11-01 16:45:57 +00:00