https://sourceware.org/bugzilla/show_bug.cgi?id=34679

--- Comment #1 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Georg-Johann Lay <[email protected]>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a7991ab4ab4a67108402eab6eabc51517b5bc000

commit a7991ab4ab4a67108402eab6eabc51517b5bc000
Author: Georg-Johann Lay <[email protected]>
Date:   Fri Oct 2 19:42:04 2026 +0200

    AVR: Prune AVR-LibC vectab with --prune-vectab during relax.

    Usually, a vector table has many unused entries that jump to
    __bad_interrupt.  This patch adds --prune-vectab as a new ld
    option that removes such unused vectab entries at the tail
    end of the vector table.  It does two things:

    * During relaxation, prune the vector table in .vectors. This
      runs prior to the ordinary relaxation that turns JMP into
      RJMP+NOP.  Most of the code is checking whether the vector
      table has the expected shape, that is:  All of .vectors is an
      array of RJMPs, or an array of JMPs, or an array of JMPs with
      one final CLH.  The latter can occur on AVR-SD where AVR-LibC
      adds a CLH after the vector table so that all executed insns
      are followed by a valid opcode.

    * During relaxation, allow to remove the last NOP when the
      last vectab entry is RJMP+NOP.

    The patch adds some new tests.  It passes the avr-gcc testsuite
    without new regressions with -mrelax -Wl,--prune-vectab compared
    against a run where only -mrelax is on; tested with ATmega128
    and ATmega8.

            PR ld/34679
    bfd/
            * elf32-avr.c (avr_prune_vectab): New static variable.
            (elf32_avr_setup_params): Set it.
            (avr_irq_t, avr_vectab_t): New typedefs.
            (rout, avr_global_symbol_address, avr_find_relocs_to_vectab)
            (avr_is_CLH, avr_reloc_global_symbol_name, avr_init_vectab):
            New static functions.
            (avr_maybe_prune_vectab): New static function.
            (elf32_avr_relax_section): Call it.  Allow to prune the last
            vectab NOP when --prune-vectab is on.
            * elf32-avr.h (elf32_avr_setup_params): Adjust prototype.
    ld/
            * NEWS (avr): Mention --prune-vectab.
            * emultempl/avrelf.em (avr_prune_vectab): New static variable.
            (avr_elf_set_global_bfd_parameters): Pass it.
            (PARSE_AND_LIST_LONGOPTS): Set it.  Add option --prune-vectab.
            * ldlex.h (OPTION_PRUNE_VECTAB): New enum option_values.
            * testsuite/ld-avr/vectab.h: New test source.
            * testsuite/ld-avr/prune-vtab-1.s: New test source.
            * testsuite/ld-avr/prune-vtab-2.s: New test source.
            * testsuite/ld-avr/vectab-rjmp.s: New test source.
            * testsuite/ld-avr/vectab-jmp.s: New test source.
            * testsuite/ld-avr/vectab-jmp-clh.s: New test source.
            * testsuite/ld-avr/prune-vtab-1a.d: New test.
            * testsuite/ld-avr/prune-vtab-1b.d: New test.
            * testsuite/ld-avr/prune-vtab-1c.d: New test.
            * testsuite/ld-avr/prune-vtab-2a.d: New test.
            * testsuite/ld-avr/prune-vtab-2b.d: New test.
            * testsuite/ld-avr/prune-vtab-2c.d: New test.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to