Commit Graph

10 Commits

Author SHA1 Message Date
H.J. Lu a39d29cda1 gas: Update fr_literal access in frag for GCC 10
When access fr_literal in

struct frag {
  ...
  /* Data begins here.  */
  char fr_literal[1];
};

with

char *buf = fragp->fr_fix + fragp->fr_literal;

GCC 10 gave

gas/config/tc-csky.c: In function ‘md_convert_frag’:
gas/config/tc-csky.c:4507:9: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
 4507 |  buf[1] = BYTE_1 (CSKYV1_INST_SUBI | (7 << 4));
      |         ^

Change

  char *buf = fragp->fr_fix + fragp->fr_literal;

to

  char *buf = fragp->fr_fix + &fragp->fr_literal[0];

to silence GCC 10 warning.

	* config/tc-csky.c (md_convert_frag): Replace fragp->fr_literal
	with &fragp->fr_literal[0].
	* config/tc-microblaze.c (md_apply_fix): Likewise.
	* config/tc-sh.c (md_convert_frag): Likewise.
2020-05-25 04:51:17 -07:00
Alan Modra a6a1f5e050 More 1 << 31 signed overflows
* config/tc-csky.c (get_operand_value): Rewrite 1 << 31 expressions
	to avoid signed overflow.
	* config/tc-mcore.c (md_assemble): Likewise.
	* config/tc-mips.c (gpr_read_mask, gpr_write_mask): Likewise.
	* config/tc-nds32.c (SET_ADDEND): Likewise.
	* config/tc-nios2.c (nios2_assemble_arg_R): Likewise.
2020-03-10 21:56:42 +10:30
Alan Modra b3adc24a07 Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
Alan Modra 4f7cc14110 gas signed overflow fixes
* config/tc-aarch64.c (get_aarch64_insn): Avoid signed overflow.
	* config/tc-metag.c (parse_dalu): Likewise.
	* config/tc-tic4x.c (md_pcrel_from): Likewise.
	* config/tc-tic6x.c (tic6x_output_unwinding): Likewise.
	* config/tc-csky.c (parse_fexp): Use an unsigned char temp buffer.
	Don't use register keyword.  Avoid signed overflow and remove now
	unneccesary char masks.  Formatting.
	* config/tc-ia64.c (operand_match): Don't use shifts to sign extend.
	* config/tc-mep.c (mep_apply_fix): Likewise.
	* config/tc-pru.c (md_apply_fix): Likewise.
	* config/tc-riscv.c (load_const): Likewise.
	* config/tc-nios2.c (md_apply_fix): Likewise.  Don't potentially
	truncate fixup before right shift.  Tidy BFD_RELOC_NIOS2_HIADJ16
	calculation.
2019-12-12 21:58:33 +10:30
Alan Modra f6bd0b7677 C-SKY FAIL: jbt - csky
Another failure seen with MALLOC_PERTURB_=1.

	* config/tc-csky.c (md_convert_frag): Initialise trailing
	padding for COND_JUMP_PIC.
2019-05-15 16:41:22 +09:30
Alan Modra 3ca4a8eca7 Assorted warning fixes
gcc-9 flagged warnings at the places I'm patching here, all real bugs.

	* config/tc-alpha.c (md_apply_fix): Correct range checks for
	BFD_RELOC_ALPHA_NOP, BFD_RELOC_ALPHA_LDA, BFD_RELOC_ALPHA_BSR.
	* config/tc-arm.c (md_apply_fix): Use llabs rather than abs.
	* config/tc-csky.c (get_macro_reg_vals): Pass s to csky_show_error.
2019-01-31 14:45:01 +10:30
Alan Modra 827041555a Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
Alan Modra 8d1015a887 Move struc-symbol.h to symbols.c
This file was never supposed to be widely used.  The fact that it has
found its way into many gas files led to bugs, typically when code
expecting a symbolS* to point at a struct symbol is presented with a
struct local_symbol.  Also, commit 158184ac9e changed these structs in
2012 but didn't catch all places where symbol bsym was being used to
test for a local_symbol.

	* Makefile.am (HFILES): Delete struc-symbol.h.
	* doc/internals.texi: Delete struc-symbol.h reference and out
	of date local symbol description.
	* struc-symbol.h: Delete.  Move contents to..
	* symbols.c: ..here.
	(symbol_on_chain, symbol_symbolS): New functions.
	* symbols.h (symbol_on_chain, symbol_symbolS): Declare.
	* cgen.c: Don't #include struc-symbol.h.
	(gas_cgen_parse_operand): Don't test for local_symbol using
	bsym, instead call symbol_symbolS.  Use symbol_get_bfdsym.
	(weak_operand_overflow_check, make_right_shifted_expr): Use
	symbol accessors.
	* config/obj-coff.c: Don't #include struc-symbol.h.
	(GET_FILENAME_STRING): Delete.
	* config/obj-elf.c: Don't #include struc-symbol.h.
	(elf_file_symbol): Use symbol accessors.
	(elf_adjust_symtab): Call symbol_on_chain.
	* config/obj-evax.c: Don't #include struc-symbol.h.
	* config/tc-nds32.c: Likewise.
	* config/tc-rl78.c: Likewise.
	* config/tc-rx.c: Likewise.
	* config/tc-alpha.c: Likewise.
	(add_to_link_pool, s_alpha_comm): Use symbol accessors.
	* config/tc-arc.c: Don't #include struc-symbol.h.
	(arc_check_relocs): Use symbol accessors, testing gas symbol
	section rather than bfd symbol section.
	* config/tc-avr.c: Don't #include struc-symbol.h.
	(avr_patch_gccisr_frag): Use symbol accessors.
	* config/tc-bfin.c: Don't #include struc-symbol.h.
	(bfin_loop_beginend): Use symbol accessors.
	* config/tc-csky.c: Don't #include struc-symbol.h.
	(v2_work_movih, v2_work_ori): Use symbol accessors.  Check for
	absolute symbol as well as O_constant.
	* config/tc-riscv.c: Don't #include struc-symbol.h.
	(riscv_pre_output_hook): Use symbol accessors.
	* config/tc-s390.c: Don't #include struc-symbol.h.
	(s390_literals): Use symbol accessors.
	* config/tc-score.c (s3_build_la_pic, s3_build_lwst_pic): Use
	symbol accessors.
	(s3_relax_branch_inst16, s3_relax_cmpbranch_inst32): Don't
	test symbol bsym.
	* config/tc-score7.c: Don't #include struc-symbol.h.
	(s7_build_la_pic, s7_build_lwst_pic): Use symbol accessors.
	(s7_b32_relax_to_b16): Don't test symbol bsym.
	* config/tc-sh.c: Don't #include struc-symbol.h.
	(insert_loop_bounds): Use symbol accessors.
	(sh_frob_section): Remove bogus symbol canonicalization.
	* config/tc-tic54x.c: Don't #include struc-symbol.h.
	(tic54x_bss): Use symbol accessors.
	* config/tc-tilegx.c: Don't #include struc-symbol.h.
	(emit_tilegx_instruction, tilegx_parse_name): Use symbol accessors.
	* config/tc-tilepro.c: Don't #include struc-symbol.h.
	(emit_tilepro_instruction, tilepro_parse_name): Use accessors.
	* config/tc-xtensa.c: Don't #include struc-symbol.h.
	(xg_assemble_vliw_tokens): Use symbol accessors.
	(xg_order_trampoline_chain): Likewise.
	* ehopt.c: Don't #include struc-symbol.h.
	(check_eh_frame): Correct local symbol test.  Use symbol accessors.
	* write.c: Don't #include struc-symbol.h.
	(create_note_reloc, maybe_generate_build_notes): Use symbol accessors.
	* Makefile.in: Regenerate.
	* po/POTFILES.in: Regenerate.
2018-10-29 18:20:48 +10:30
Lifang Xia fe75f42ee1 csky: Support PC relative diff relocation
Define DIFF_EXPR_OK to Support PC relative diff relocation,
and add CKCORE_PCREL32 relocation process

bfd/
        * elf32-csky.c (csky_elf_howto_table): Fill special_function of
        R_CKCORE_PCREL32.
        (csky_elf_relocate_section): Add R_CKCORE_PCREL32 process.
gas/
        * config/tc-csky.c (md_apply_fix): Transmit
        BFD_RELOC_32_PCREL to BFD_RELOC_CKCORE_PCREL32.
        (tc_gen_reloc): Trasmit BFD_RELOC_CKCORE_ADDR32 to
        BFD_RELOC_CKCORE_PCREL32 while pc-relative.
        * config/tc-csky.h (DIFF_EXPR_OK): Define to enable PC relative
        diff relocs.
2018-09-14 21:04:47 +08:00
Andrew Jenner b8891f8d62 Add support for the C_SKY series of processors.
This patch series is a new binutils port for C-SKY processors, including support for both the V1 and V2 processor variants.  V1 is derived from the MCore architecture while V2 is substantially different, with mixed 16- and 32-bit instructions, a larger register set, a different (but overlapping) ABI, etc.  There is support for bare-metal ELF targets and Linux with both glibc and uClibc.

This code is being contributed jointly by C-SKY Microsystems and Mentor Graphics.  C-SKY is responsible for the technical content and has proposed Lifang Xia and Yunhai Shang as port maintainers.  (Note that C-SKY does have a corporate copyright assignment on file with the FSF.) Mentor Graphics' role has been cleaning up the code, adding documentation and additional test cases, etc, to address issues we anticipated reviewers would complain about.

bfd     * Makefile.am (ALL_MACHINES, ALL_MACHINES_CFILES): Add C-SKY.
        (BFD32_BACKENDS, BFD_BACKENDS_CFILES): Likewise.
        * Makefile.in: Regenerated.
        * archures.c (enum bfd_architecture): Add bfd_arch_csky and
        related bfd_mach defines.
        (bfd_csky_arch): Declare.
        (bfd_archures_list): Add C-SKY.
        * bfd-in.h (elf32_csky_build_stubs): Declare.
        (elf32_csky_size_stubs): Declare.
        (elf32_csky_next_input_section: Declare.
        (elf32_csky_setup_section_lists): Declare.
        * bfd-in2.h: Regenerated.
        * config.bfd: Add C-SKY.
        * configure.ac: Likewise.
        * configure: Regenerated.
        * cpu-csky.c: New file.
        * elf-bfd.h (enum elf_target_id): Add C-SKY.
        * elf32-csky.c: New file.
        * libbfd.h: Regenerated.
        * reloc.c: Add C-SKY relocations.
        * targets.c (csky_elf32_be_vec, csky_elf32_le_vec): Declare.
        (_bfd_target_vector): Add C-SKY target vector entries.

binutils* readelf.c: Include elf/csky.h.
        (guess_is_rela): Handle EM_CSKY.
        (dump_relocations): Likewise.
        (get_machine_name): Likewise.
        (is_32bit_abs_reloc): Likewise.

include  * dis-asm.h (csky_symbol_is_valid): Declare.
         * opcode/csky.h: New file.

opcodes  * Makefile.am (TARGET_LIBOPCODES_CFILES): Add csky-dis.c.
         * Makefile.in: Regenerated.
         * configure.ac: Add C-SKY.
         * configure: Regenerated.
         * csky-dis.c: New file.
         * csky-opc.h: New file.
         * disassemble.c (ARCH_csky): Define.
         (disassembler, disassemble_init_for_target): Add case for ARCH_csky.
         * disassemble.h (print_insn_csky, csky_get_disassembler): Declare.

gas      * Makefile.am (TARGET_CPU_CFILES): Add entry for C-SKY.
         (TARGET_CPU_HFILES, TARGET_ENV_HFILES): Likewise.
         * Makefile.in: Regenerated.
         * config/tc-csky.c: New file.
         * config/tc-csky.h: New file.
         * config/te-csky_abiv1.h: New file.
         * config/te-csky_abiv1_linux.h: New file.
         * config/te-csky_abiv2.h: New file.
         * config/te-csky_abiv2_linux.h: New file.
         * configure.tgt: Add C-SKY.
         * doc/Makefile.am (CPU_DOCS): Add entry for C-SKY.
         * doc/Makefile.in: Regenerated.
         * doc/all.texi: Set CSKY feature.
         * doc/as.texi (Overview): Add C-SKY options.
         (Machine Dependencies): Likewise.
         * doc/c-csky.texi: New file.
         * testsuite/gas/csky/*: New test cases.

ld      * Makefile.am (ALL_EMULATION_SOURCES): Add C-SKY emulations.
        (ecskyelf.c, ecskyelf_linux.c): New rules.
        * Makefile.in: Regenerated.
        * configure.tgt: Add C-SKY.
        * emulparams/cskyelf.sh: New file.
        * emulparams/cskyelf_linux.sh: New file.
        * emultempl/cskyelf.em: New file.
        * gen-doc.texi: Add C-SKY.
        * ld.texi: Likewise.
        (Options specific to C-SKY targets): New section.
        * testsuite/ld-csky/*: New tests.
2018-07-30 12:24:14 +01:00