commit 8f99238d69b5e3101a73bbaaa011913b58a55b8c (HEAD -> gentoo/binutils-2.39, gentoo/gentoo/binutils-2.39)
Author: Alan Modra <amodra@gmail.com>
Date:   Sun Sep 25 12:07:36 2022 +0930

    PR29542, PowerPC gold internal error in get_output_view,
    
    We were attempting to set a BSS style section contents.
    
            PR 29542
            * powerpc.cc (Output_data_plt_powerpc::do_write): Don't set .plt,
            .iplt or .lplt section contents when position independent.
    
    (cherry picked from commit c21736aed1d4877e090df60362413669dbdc391d)
    (cherry picked from commit 041c22e35de06d22566f4c71e4425c3351215e66)

 gold/powerpc.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

commit 83894445e8a11a1053fe806012de3cf8bcb7c2b3
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Aug 1 16:02:39 2022 -0700

    elf: Reset alignment for each PT_LOAD segment
    
    Reset alignment for each PT_LOAD segment to avoid using alignment from
    the previous PT_LOAD segment.
    
    bfd/
    
            PR ld/29435
            * elf.c (assign_file_positions_for_load_sections): Reset
            alignment for each PT_LOAD segment.
    
    ld/
    
            PR ld/29435
            * testsuite/ld-elf/pr29435.d: New file.
            * testsuite/ld-elf/pr29435.s: Likewise.
    
    (cherry picked from commit 59f214544c50ec7ebbca285ff2b4949f48671690)
    (cherry picked from commit a98316d5cf970cbc99689797d84c2ea832bcdcbb)

 bfd/elf.c                     |  7 ++++---
 ld/testsuite/ld-elf/pr29435.d | 11 +++++++++++
 ld/testsuite/ld-elf/pr29435.s |  6 ++++++
 3 files changed, 21 insertions(+), 3 deletions(-)

commit 796fbbd0bd0fe5de3c67a661de19f343015fa064
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Sep 21 09:06:29 2022 +0930

    Re: PowerPC64 pcrel got relocs against local symbols
    
    The last patch wasn't all that shiny.  There are rather a lot more
    relocations that can hit the assertion in md_apply_fix if the symbol
    is local or absolute.  Fix them all.
    
            * config/tc-ppc.c (ppc_force_relocation): Add all relocs that
            expect a symbol in md_apply_fix.  Remove tls pcrel relocs
            already covered in general tls match range.
    
    (cherry picked from commit 8b168f1a1e09e337d2a970f204a0230c091bbe58)
    (cherry picked from commit 010db38b54b589ca3e95b498aba2831064970171)

 gas/config/tc-ppc.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 52 insertions(+), 6 deletions(-)

commit 6ca71356bb8b4d91f4d394fa4002be4363f3f798
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Sep 16 18:08:44 2022 +0930

    PowerPC64 pcrel got relocs against local symbols
    
    Not that anyone would want to indirect via the GOT when an address can
    be loaded directly with pla, the following:
    
     pld 3,x@got@pcrel
    x:
    
    leads to "Internal error in md_apply_fix", because the generic parts
    of assembler fixup handling convert the fx_pcrel fixup to one without
    a symbol.  Stop that happening.
    
            * config/tc-ppc.c (ppc_force_relocation): Add PLT_PCREL34 and
            assorted GOT_PCREL34 relocs.
    
    (cherry picked from commit 49c3ed081fed6b8e2b48fdc48f805f11e4589514)
    (cherry picked from commit 4d7bba23a39fba18d6d13a2941a3c232011a7064)

 gas/config/tc-ppc.c | 6 ++++++
 1 file changed, 6 insertions(+)

commit e595d61f188bcca2a26270ef9b4085306498159f
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Sep 10 07:30:57 2022 +0930

    Re: PR29466, APP/NO_APP with linefile
    
    It looks like I copied the SIZE init across from
    binutils/testsuite/config/default.exp without some necessary editing.
    
            PR 29466
            * testsuite/config/default.exp (SIZE): Adjust relative path.
    
    (cherry picked from commit 1180f540d5f2f7751b5309bdd6c38d69fcf699e7)
    (cherry picked from commit 4233be14a34d754a70b8b6f6fa42d21f35c6e030)

 gas/testsuite/config/default.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

commit 4d3f120ce813794267c4a5849f2e216e95757ad4 (2.39-loongarch-updates)
Author: liuzhensong <liuzhensong@loongson.cn>
Date:   Thu Aug 4 14:30:39 2022 +0800

    LoongArch: Update ELF e_flags handling according to specification.
    
      Update handling of e_flags according to the documentation
      update [1] (discussions [2][3]).
    
      Object file bitness is now represented in the EI_CLASS byte.
      The e_flags field is now interpreted as follows:
    
      e_flags[2:0]: Base ABI modifier
    
      - 0x1: soft-float
      - 0x2: single-precision hard-float
      - 0x3: double-precision hard-float
    
      e_flags[7:6]: ELF object ABI version
    
      - 0x0: v0
      - 0x1: v1
    
      [1]: https://github.com/loongson/LoongArch-Documentation/blob/main/docs/LoongArch-ELF-ABI-EN.adoc#e_flags-identifies-abi-type-and-version
      [2]: https://github.com/loongson/LoongArch-Documentation/pull/61
      [3]: https://github.com/loongson/LoongArch-Documentation/pull/47
    
    (cherry picked from commit c4a7e6b56218e1d5a858682186b542e2eae01a4a)

 bfd/elfnn-loongarch.c     | 21 ++++++++++++++++++---
 binutils/readelf.c        | 10 +++++-----
 gas/config/tc-loongarch.c | 20 ++++++++++----------
 include/elf/loongarch.h   | 44 +++++++++++++++++++++-----------------------
 4 files changed, 54 insertions(+), 41 deletions(-)

commit 15d6d86242ff4a96a0e789d99891af5d3bf1beb0
Author: liuzhensong <liuzhensong@loongson.cn>
Date:   Thu Aug 4 14:49:40 2022 +0800

    LoongArch: Set macro SUB_SEGMENT_ALIGN to 0.
    
    (cherry picked from commit 13d4a5f7b6c37607106cca0833e03075983bcc3b)

 gas/config/tc-loongarch.h | 2 ++
 1 file changed, 2 insertions(+)

commit e4446122c40c98a5e16b5263a3f4f6452b275061
Author: Xi Ruoyao <xry111@xry111.site>
Date:   Tue Sep 20 14:09:30 2022 +0800

    LoongArch: Fix R_LARCH_IRELATIVE insertion after elf_link_sort_relocs
    
    loongarch_elf_finish_dynamic_symbol is called after elf_link_sort_relocs
    if -z combreloc.  elf_link_sort_relocs redistributes the contents of
    .rela.* sections those would be merged into .rela.dyn, so the slot for
    R_LARCH_IRELATIVE may be out of relplt->contents now.
    
    To make things worse, the boundary check
    
        dyn < dyn + relplt->size / sizeof (*dyn)
    
    is obviously wrong ("x + 10 < x"? :), causing the issue undetected
    during the linking process and the resulted executable suddenly crashes
    at runtime.
    
    The issue was found during an attempt to add static-pie support to the
    toolchain.
    
    Fix it by iterating through the inputs of .rela.dyn to find the slot.
    
    (cherry picked from commit ae2e4d4035f511543d12f74b3b7fdb1ba0daab16)

 bfd/elfnn-loongarch.c                              | 41 +++++++++++++---------
 ld/testsuite/ld-loongarch-elf/ld-loongarch-elf.exp |  1 +
 ld/testsuite/ld-loongarch-elf/local-ifunc-reloc.d  | 10 ++++++
 ld/testsuite/ld-loongarch-elf/local-ifunc-reloc.s  | 28 +++++++++++++++
 4 files changed, 63 insertions(+), 17 deletions(-)

commit 3b8cf95f16b3fe3e9bdd7c281f00ae16e83d38c9
Author: Xi Ruoyao <xry111@xry111.site>
Date:   Tue Sep 20 14:09:29 2022 +0800

    LoongArch: Don't write into GOT for local ifunc
    
    Local ifuncs are always resolved at runtime via R_LARCH_IRELATIVE, so
    there is no need to write anything into GOT.  And when we write the GOT
    we actually trigger a heap-buffer-overflow: If a and b are different
    sections, we cannot access something in b with "a->contents + (offset
    from a)" because "a->contents" and "b->contents" are heap buffers
    allocated separately, not slices of a large buffer.
    
    So stop writing into GOT for local ifunc now.
    
    (cherry picked from commit 6224a6c2ead26a04f0b2b8ccf4ff5b817afbb425)

 bfd/elfnn-loongarch.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

commit 05cc6b24c371fb4af93707e8e17672863861c889
Author: mengqinggang <mengqinggang@loongson.cn>
Date:   Tue Aug 30 16:27:55 2022 +0800

    LoongArch: fix gas BFD_RELOC_8/16/24 bug
    
    If fixP->fx_subsy is NULL, BFD_RELOC_8/16/24 can't convert to
    BFD_RELOC_LARCH_xxx.
    
    gas/config/tc-loongarch.c
    
    (cherry picked from commit f555b327d41ed72ffae28caae550f5f86312db43)

 gas/config/tc-loongarch.c                 | 59 +++++++++++++++++++++----------
 gas/testsuite/gas/loongarch/bfd_reloc_8.s | 16 +++++++++
 gas/testsuite/gas/loongarch/loongarch.exp |  1 +
 3 files changed, 58 insertions(+), 18 deletions(-)

commit 35568255fa56167ec577d46f87246bec3d11f266
Author: liuzhensong <liuzhensong@loongson.cn>
Date:   Tue Aug 30 11:53:15 2022 +0800

    LoongArch: Fix redefinition of "PACKAGE".
    
      Running configure and make in binutils-gdb.
    
      $ ./configure
      $ make
    In file included from ./as.h:37,
                     from ./config/loongarch-lex.l:21,
                     from config/loongarch-lex-wrapper.c:20:
    ./config.h:206: error: “PACKAGE” redefined [-Werror]
     #define PACKAGE "gas"
    ...
    
      gas/config
      *  loongarch-lex-wrapper.c
    
    (cherry picked from commit df4febc60037a1f357414667ff07498cf225c22e)

 gas/config/loongarch-lex-wrapper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

commit 7a297012b7b293bf3ccc506b8bfac37663b386de
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Aug 25 09:23:59 2022 +0930

    Re: LoongArch: ld: Fix bug not generate plt when link a dso
    
    Fixes loongarch32-elf  +FAIL: medium jirl plt
    
            * testsuite/ld-loongarch-elf/cmodel.exp: Don't run test when
            no shared library support.
    
    (cherry picked from commit c6e42384f1a1fe678ae947afd3558b5188c3e10e)

 ld/testsuite/ld-loongarch-elf/cmodel.exp | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

commit 8a392b8120ab4497cb572f74f4a3b353309d84ba
Author: liuzhensong <liuzhensong@loongson.cn>
Date:   Fri Aug 19 15:04:45 2022 +0800

    LoongArch: ld: Fix bug not generate plt when link a dso
    
      Fix the bug that can not generate func@plt
      when linking a undefined function with cmodel=medium.
      Add testcase.
    
      bfd/
        * elfnn-loongarch.c
      ld/testsuite/ld-loongarch-elf/
        * cmodel-libjirl.dd
        * cmodel.exp
        * libjirl.s
    
    (cherry picked from commit 42bd5254fb5f52f045796e1d9cce07102881d3b1)

 bfd/elfnn-loongarch.c                           |  6 ++++
 ld/testsuite/ld-loongarch-elf/cmodel-libjirl.dd |  4 +++
 ld/testsuite/ld-loongarch-elf/cmodel.exp        | 37 +++++++++++++++++++++++++
 ld/testsuite/ld-loongarch-elf/libjirl.s         |  2 ++
 4 files changed, 49 insertions(+)

commit 0cf8fcb0dc8422c3569443946fb0eedd27ec4d10
Author: tangxiaolin <tangxiaolin@loongson.cn>
Date:   Wed Aug 17 15:12:43 2022 +0800

    LoongArch: gas: add support using constant variable in instructions.
    
            Instructions that can load immediate support using constant
            variable like ".equ var, 123    li.w/d resgister, var".
    
    gas/
            * config/loongarch-parse.y
            * config/tc-loongarch.c
    
            Add four testcases.One is a program using constant variable,
            one test using label is unsupported, and another two test
            almost instructions that can load immediate.
    
    gas/
            * testsuite/gas/loongarch/li.d
            * testsuite/gas/loongarch/li.s
            * testsuite/gas/loongarch/imm_ins_label-fail.d
            * testsuite/gas/loongarch/imm_ins_label-fail.l
            * testsuite/gas/loongarch/imm_ins_label-fail.s
            * testsuite/gas/loongarch/imm_ins.d
            * testsuite/gas/loongarch/imm_ins.s
            * testsuite/gas/loongarch/imm_ins_32.d
            * testsuite/gas/loongarch/imm_ins_32.s
    
    (cherry picked from commit 7ec249249cd4d1a31bdb9318dba7510f33d866df)

 gas/config/loongarch-parse.y                     | 20 ++++++
 gas/config/tc-loongarch.c                        | 18 -----
 gas/testsuite/gas/loongarch/imm_ins.d            | 80 +++++++++++++++++++++++
 gas/testsuite/gas/loongarch/imm_ins.s            | 83 ++++++++++++++++++++++++
 gas/testsuite/gas/loongarch/imm_ins_32.d         | 57 ++++++++++++++++
 gas/testsuite/gas/loongarch/imm_ins_32.s         | 60 +++++++++++++++++
 gas/testsuite/gas/loongarch/imm_ins_label-fail.d |  3 +
 gas/testsuite/gas/loongarch/imm_ins_label-fail.l |  3 +
 gas/testsuite/gas/loongarch/imm_ins_label-fail.s |  3 +
 gas/testsuite/gas/loongarch/li.d                 | 21 ++++++
 gas/testsuite/gas/loongarch/li.s                 | 22 +++++++
 11 files changed, 352 insertions(+), 18 deletions(-)

commit 5bb398751fd743c7a5569fe04363f38727fd840e
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Aug 19 10:23:11 2022 +0930

    loongarch64_pei_vec garbage in objcopy'd relocs
    
    Like commit a9c09a3667cc, but for loongarch64.
    
            * coff-loongarch64.c (SWAP_IN_RELOC_OFFSET): Define.
            (SWAP_OUT_RELOC_OFFSET): Define.
    
    (cherry picked from commit 866318daa306987c1d57f0b79241e7f38fb9dd4d)

 bfd/coff-loongarch64.c | 4 ++++
 1 file changed, 4 insertions(+)

commit 1a4159949d4b339a93932775c1e76681a401c536
Author: Youling Tang <tangyouling@loongson.cn>
Date:   Sat Aug 6 14:49:43 2022 +0800

    bfd: Add support for LoongArch64 EFI (efi-*-loongarch64).
    
    This adds support for efi-loongarch64 by virtue of adding a new PEI target
    pei-loongarch64.  This is not a full target and only exists to support EFI at
    this time.
    
    This means that this target does not support relocation processing and is mostly
    a container format.  This format has been added to elf based loongarch64 targets
    such that efi images can be made natively on Linux.
    
    However this target is not valid for use with gas but only with objcopy.
    
    We should't limit addresses to 32-bits for 64-bit vma, otherwise there will be
    "RVA truncated" error when using objcopy on loongarch64.
    
    With these changes the resulting file is recognized as an efi image.
    
    Any magic number is based on the Microsoft PE specification [1].
    
    The test results are as follows:
    $ make check-binutils RUNTESTFLAGS='loongarch64.exp'
      PASS: Check if efi app format is recognized
    
    $ objdump -h -f tmpdir/loongarch64copy.o
      tmpdir/loongarch64copy.o:     file format pei-loongarch64
      architecture: Loongarch64, flags 0x00000132:
      EXEC_P, HAS_SYMS, HAS_LOCALS, D_PAGED
      start address 0x0000000000000000
    
      Sections:
      Idx Name          Size      VMA               LMA               File off  Algn
        0 .text         0000003c  00000000200000b0  00000000200000b0  00000200  2**2
                        CONTENTS, ALLOC, LOAD, READONLY, CODE
    
    [1] https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
    
    bfd:
      * .gitignore (pe-loongarch64igen.c): New.
      * Makefile.am (pei-loongarch64.lo, pe-loongarch64igen.lo, pei-loongarch64.c,
      pe-loongarch64igen.c): Add support.
      * Makefile.in: Likewise.
      * bfd.c (bfd_get_sign_extend_vma): Add pei-loongarch64.
      * coff-loongarch64.c: New file.
      * coffcode.h (coff_set_arch_mach_hook, coff_set_flags,
      coff_write_object_contents) Add loongarch64 (loongarch64_pei_vec) support.
      * config.bfd: Likewise.
      * configure: Likewise.
      * configure.ac: Likewise.
      * libpei.h (GET_OPTHDR_IMAGE_BASE, PUT_OPTHDR_IMAGE_BASE,
      GET_OPTHDR_SIZE_OF_STACK_RESERVE, PUT_OPTHDR_SIZE_OF_STACK_RESERVE,
      GET_OPTHDR_SIZE_OF_STACK_COMMIT, PUT_OPTHDR_SIZE_OF_STACK_COMMIT,
      GET_OPTHDR_SIZE_OF_HEAP_RESERVE, PUT_OPTHDR_SIZE_OF_HEAP_RESERVE,
      GET_OPTHDR_SIZE_OF_HEAP_COMMIT, PUT_OPTHDR_SIZE_OF_HEAP_COMMIT,
      GET_PDATA_ENTRY, _bfd_peLoongArch64_bfd_copy_private_bfd_data_common,
      _bfd_peLoongArch64_bfd_copy_private_section_data,
      _bfd_peLoongArch64_get_symbol_info, _bfd_peLoongArch64_only_swap_filehdr_out,
      _bfd_peLoongArch64_print_private_bfd_data_common,
      _bfd_peLoongArch64i_final_link_postscript,
      _bfd_peLoongArch64i_only_swap_filehdr_out, _bfd_peLoongArch64i_swap_aouthdr_in,
      _bfd_peLoongArch64i_swap_aouthdr_out, _bfd_peLoongArch64i_swap_aux_in,
      _bfd_peLoongArch64i_swap_aux_out, _bfd_peLoongArch64i_swap_lineno_in,
      _bfd_peLoongArch64i_swap_lineno_out, _bfd_peLoongArch64i_swap_scnhdr_out,
      _bfd_peLoongArch64i_swap_sym_in, _bfd_peLoongArch64i_swap_sym_out,
      _bfd_peLoongArch64i_swap_debugdir_in, _bfd_peLoongArch64i_swap_debugdir_out,
      _bfd_peLoongArch64i_write_codeview_record,
      _bfd_peLoongArch64i_slurp_codeview_record,
      _bfd_peLoongArch64_print_ce_compressed_pdata): New.
      * peXXigen.c (_bfd_XXi_swap_aouthdr_in, _bfd_XXi_swap_aouthdr_out,
      _bfd_XXi_swap_scnhdr_out, pe_print_pdata, _bfd_XX_print_private_bfd_data_common,
      _bfd_XX_bfd_copy_private_section_data, _bfd_XXi_final_link_postscript):
      Support COFF_WITH_peLoongArch64,
      * pei-loongarch64.c: New file.
      * peicode.h (coff_swap_scnhdr_in, pe_ILF_build_a_bfd, pe_ILF_object_p):
      Support COFF_WITH_peLoongArch64.
      (jtab): Add dummy entry that traps.
      * targets.c (loongarch64_pei_vec): New.
    
    binutils
      * testsuite/binutils-all/loongarch64/loongarch64.exp: New file.
      * testsuite/binutils-all/loongarch64/pei-loongarch64.d: New test.
      * testsuite/binutils-all/loongarch64/pei-loongarch64.s: New test.
    
    include
      * coff/loongarch64.h: New file.
      * coff/pe.h (IMAGE_FILE_MACHINE_LOONGARCH64): New.
    
    Signed-off-by: Youling Tang <tangyouling@loongson.cn>
    (cherry picked from commit 31f6009538b75c22a4b3f99216846973283f0c6d)

 bfd/.gitignore                                     |   1 +
 bfd/Makefile.am                                    |   9 +-
 bfd/Makefile.in                                    |  11 +-
 bfd/bfd.c                                          |   1 +
 bfd/coff-loongarch64.c                             | 165 +++++++++++++++++++++
 bfd/coffcode.h                                     |  19 ++-
 bfd/config.bfd                                     |   2 +-
 bfd/configure                                      |   1 +
 bfd/configure.ac                                   |   1 +
 bfd/libpei.h                                       |  36 +++++
 bfd/peXXigen.c                                     |  49 +++---
 bfd/pei-loongarch64.c                              |  75 ++++++++++
 bfd/peicode.h                                      |  21 ++-
 bfd/targets.c                                      |   2 +
 .../binutils-all/loongarch64/loongarch64.exp       |  30 ++++
 .../binutils-all/loongarch64/pei-loongarch64.d     |  15 ++
 .../binutils-all/loongarch64/pei-loongarch64.s     |  33 +++++
 include/coff/loongarch64.h                         |  61 ++++++++
 include/coff/pe.h                                  |   1 +
 19 files changed, 506 insertions(+), 27 deletions(-)

commit 0210487a98c3233c16fc4631defa6971e7e229e4 (tag: gentoo/binutils-2.39-4, github/gentoo/binutils-2.39)
Author: Alan Modra <amodra@gmail.com>
Date:   Thu Aug 11 09:51:03 2022 +0930

    PR29466, APP/NO_APP with .linefile
    
    Commit 53f2b36a54b9 exposed a bug in sb_scrub_and_add_sb that could
    result in losing input.  If scrubbing results in expansion past the
    holding capacity of do_scrub_chars output buffer, then do_scrub_chars
    stashes the extra input for the next call.  That call never came
    because sb_scrub_and_add_sb wrongly decided it was done.  Fix that by
    allowing sb_scrub_and_add_sb to see whether there is pending input.
    Also allow a little extra space so that in most cases we won't need
    to resize the output buffer.
    
    sb_scrub_and_add_sb also limited output to the size of the input,
    rather than the actual output buffer size.  Fixing that resulted in a
    fail of gas/testsuite/macros/dot with an extra warning: "end of file
    not at end of a line; newline inserted".  OK, so the macro in dot.s
    really does finish without end-of-line.  Apparently the macro
    expansion code relied on do_scrub_chars returning early.  So fix that
    too by adding a newline if needed in macro_expand_body.
    
            PR 29466
            * app.c (do_scrub_pending): New function.
            * as.h: Declare it.
            * input-scrub.c (input_scrub_include_sb): Add extra space for
            two .linefile directives.
            * sb.c (sb_scrub_and_add_sb): Take into account pending input.
            Allow output to max.
            * macro.c (macro_expand_body): Add terminating newline.
            * testsuite/config/default.exp (SIZE, SIZEFLAGS): Define.
            * testsuite/gas/macros/app5.d,
            * testsuite/gas/macros/app5.s: New test.
            * testsuite/gas/macros/macros.exp: Run it.
    
    (cherry picked from commit 4d74aab7aa562fe79d4669cdad0c32610531cbc0)
    (cherry picked from commit 9e855cffa1fda44629e7f9b76dfa3e5a51a440e9)

 gas/app.c                           | 13 +++++++++++++
 gas/as.h                            |  1 +
 gas/input-scrub.c                   |  6 ++++--
 gas/macro.c                         |  2 ++
 gas/sb.c                            |  5 +++--
 gas/testsuite/config/default.exp    |  8 ++++++++
 gas/testsuite/gas/macros/app5.d     |  6 ++++++
 gas/testsuite/gas/macros/app5.s     |  5 +++++
 gas/testsuite/gas/macros/macros.exp |  1 +
 9 files changed, 43 insertions(+), 4 deletions(-)

commit 7874e235304c96e8d55675e84becd3aee60f0af8
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Aug 10 10:38:52 2022 +0930

    PR29462, internal error in relocate, at powerpc.cc:10796
    
    Prior to the inline plt call support (commit 08be322439), the only
    local syms with plt entries were local ifunc symbols.  There shouldn't
    be stubs for other local symbols so don't look for them.  The patch
    also fixes minor bugs in get_reference_flags; Many relocs are valid
    only for ppc64 and a couple only for ppc32.
    
            PR 29462
            * powerpc.cc (Target_powerpc::Relocate::relocate): Rename
            use_plt_offset to pltcal_to_direct, invert logic.  For relocs
            not used with inline plt sequences against local symbols, only
            look for stubs when the symbol is an ifunc.
            (Target_powerpc::Scan::get_reference_flags): Correct reloc
            handling for relocs not valid for both 32-bit and 64-bit.
    
    (cherry picked from commit 6158b25f77db11712b84e6a4609898f2615ac749)
    (cherry picked from commit e3b5d935247084dca057dea72be61b063fe2357a)

 gold/powerpc.cc | 129 ++++++++++++++++++++++++++++++++------------------------
 1 file changed, 75 insertions(+), 54 deletions(-)

commit 085131c73b69dd8e49434d1af966bd503a8f4bc8
Author: Jan Beulich <jbeulich@suse.com>
Date:   Wed Aug 10 10:34:22 2022 +0200

    gas/Dwarf: properly skip zero-size functions
    
    PR gas/29451
    
    While out_debug_abbrev() properly skips such functions, out_debug_info()
    mistakenly didn't. It needs to calculate the high_pc expression ahead of
    time, in order to skip emitting any data for the function if the value
    is zero.
    
    The one case which would still leave a zero-size entry is when
    symbol_get_obj(symp)->size ends up evaluating to zero. I hope we can
    expect that to not be the case, otherwise we'd need to have a way to
    post-process .debug_info contents between resolving expressions and
    actually writing the data out to the file. Even then it wouldn't be
    entirely obvious in which way to alter the data.
    
    (cherry picked from commit d7abcbcea5ddd40a3bf28758b62f35933c59f996)
    (cherry picked from commit e8cf73215187b0c08679d726a5cc7c019fa3ea2e)

 gas/dwarf2dbg.c | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

commit a91e5ab475567df5d4c960352cae75a1095b42cf
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Aug 8 13:22:26 2022 +0200

    ld: fix NEWS typos
    
    ld/ChangeLog:
    
            * NEWS: Fix 2 typos.
    
    (cherry picked from commit 9284b63ea39cecbfc1522d9e143ecb7727d77eb5)

 ld/NEWS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

commit 3476ee9a49d4d126d66b4ac0ac327239d523021e (tag: gentoo/binutils-2.39-3)
Author: WANG Xuerui <git@xen0n.name>
Date:   Wed Jul 27 19:07:57 2022 +0800

    opcodes: LoongArch: add "ret" instruction to reduce typing
    
    This syntactic sugar is present in both classical and emerging
    architectures, like Alpha, SPARC and RISC-V, and assembler macros
    doing the same thing can already be found in the wild e.g. [1], proving
    the feature's popularity. It's better to provide support directly in the
    assembler so downstream users wouldn't have to re-invent this over and
    over again.
    
    [1]: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/loongarch/sysdep.h;h=c586df819cd90;hb=HEAD#l28
    
    (cherry picked from commit 20f2e2686c79a5ac951f0cc283f385c16bda5d50)

 gas/testsuite/gas/loongarch/jmp_op.d   | 1 +
 gas/testsuite/gas/loongarch/jmp_op.s   | 1 +
 ld/testsuite/ld-loongarch-elf/jmp_op.d | 1 +
 ld/testsuite/ld-loongarch-elf/jmp_op.s | 1 +
 opcodes/loongarch-opc.c                | 1 +
 5 files changed, 5 insertions(+)

commit f57cdf9a3147d853e20ebc36b4a984da00eb2660
Author: WANG Xuerui <git@xen0n.name>
Date:   Wed Jul 27 19:07:56 2022 +0800

    opcodes: LoongArch: make all non-native jumps desugar to canonical b{lt/ge}[u] forms
    
    Also re-order the jump/branch opcodes while at it, so that insns are
    sorted in ascending order according to opcodes, and the label form
    preceding the real definition.
    
    (cherry picked from commit 3f6e97039ec6f476b6fe09768f4b89722ffef10f)

 gas/testsuite/gas/loongarch/jmp_op.d   |  6 ++---
 ld/testsuite/ld-loongarch-elf/jmp_op.d | 42 +++++++++++++++++-----------------
 opcodes/loongarch-opc.c                | 31 ++++++++++---------------
 3 files changed, 36 insertions(+), 43 deletions(-)

commit 7ce7f5695ddd842a209885600def6800c5284f40
Author: liuzhensong <liuzhensong@loongson.cn>
Date:   Mon Jul 25 10:22:27 2022 +0800

    LoongArch: Set defaults to exec stack 0.
    
    (cherry picked from commit 48ca1b26b99c8fd5bc21f5c69b6b666d9b6b9726)

 bfd/elfnn-loongarch.c       | 1 +
 ld/testsuite/ld-elf/elf.exp | 1 +
 2 files changed, 2 insertions(+)

commit 876fd2a74ef6c6a7d3729e2e2538026a4376bb42
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Jul 26 11:33:51 2022 +0100

    Fix indentation in loongarch code, preventing a compile time warning.
    
    (cherry picked from commit 27121f6740fa2051609b2d781d77c4cd23aa590b)

 bfd/ChangeLog         |  5 +++++
 bfd/elfnn-loongarch.c | 22 ++++++++++------------
 2 files changed, 15 insertions(+), 12 deletions(-)

commit aa40e61dc266ebbb3b7f6305378cb50f38679463
Author: liuzhensong <liuzhensong@loongson.cn>
Date:   Mon Jul 11 11:02:44 2022 +0800

    LoongArch: Add testcases for new relocate types.
    
      gas/testsuite/gas/all/
        gas.exp
      gas/testsuite/gas/loongarch/
        jmp_op.d
        jmp_op.s
        macro_op.d
        macro_op.s
        macro_op_32.d
        macro_op_32.s
        macro_op_large_abs.d
        macro_op_large_abs.s
        macro_op_large_pc.d
        macro_op_large_pc.s
        reloc.d
        reloc.s
    
      ld/testsuite/ld-elf/
        pr26936.d
        shared.exp
      ld/testsuite/ld-loongarch-elf/
        attr-ifunc-4.c
        attr-ifunc-4.out
        disas-jirl.d
        ifunc.exp
        jmp_op.d
        jmp_op.s
        libnopic-global.s
        macro_op.d
        macro_op.s
        macro_op_32.d
        macro_op_32.s
        nopic-global-so.rd
        nopic-global-so.sd
        nopic-global.out
        nopic-global.s
        nopic-global.sd
        nopic-global.xd
        nopic-local.out
        nopic-local.rd
        nopic-local.s
        nopic-local.sd
        nopic-local.xd
        nopic-weak-global-so.rd
        nopic-weak-global-so.sd
        nopic-weak-global.out
        nopic-weak-global.s
        nopic-weak-global.sd
        nopic-weak-global.xd
        nopic-weak-local.out
        nopic-weak-local.rd
        nopic-weak-local.s
        nopic-weak-local.sd
        nopic-weak-local.xd
        pic.exp
        pic.ld
    
    (cherry picked from commit 2cb10f02b0e0d0d062c97c19defef1e5e334b13b)

 gas/testsuite/gas/all/gas.exp                      |   4 +-
 gas/testsuite/gas/loongarch/jmp_op.d               |  82 +-
 gas/testsuite/gas/loongarch/jmp_op.s               |  38 +-
 gas/testsuite/gas/loongarch/macro_op.d             | 778 ++----------------
 gas/testsuite/gas/loongarch/macro_op.s             |  44 +-
 gas/testsuite/gas/loongarch/macro_op_32.d          |  55 ++
 gas/testsuite/gas/loongarch/macro_op_32.s          |  16 +
 gas/testsuite/gas/loongarch/macro_op_large_abs.d   |  77 ++
 gas/testsuite/gas/loongarch/macro_op_large_abs.s   |   9 +
 gas/testsuite/gas/loongarch/macro_op_large_pc.d    |  77 ++
 gas/testsuite/gas/loongarch/macro_op_large_pc.s    |   9 +
 gas/testsuite/gas/loongarch/reloc.d                | 167 ++++
 gas/testsuite/gas/loongarch/reloc.s                | 144 ++++
 ld/testsuite/ld-elf/pr26936.d                      |   2 +-
 ld/testsuite/ld-elf/shared.exp                     |   6 +-
 ld/testsuite/ld-loongarch-elf/attr-ifunc-4.c       |  23 +
 ld/testsuite/ld-loongarch-elf/attr-ifunc-4.out     |   1 +
 ld/testsuite/ld-loongarch-elf/disas-jirl-32.d      |  18 +-
 ld/testsuite/ld-loongarch-elf/disas-jirl.d         |  19 +-
 ld/testsuite/ld-loongarch-elf/ifunc.exp            |  34 +
 ld/testsuite/ld-loongarch-elf/jmp_op.d             |  84 +-
 ld/testsuite/ld-loongarch-elf/jmp_op.s             |  42 +-
 ld/testsuite/ld-loongarch-elf/libnopic-global.s    | 113 +++
 ld/testsuite/ld-loongarch-elf/macro_op.d           | 883 ++++-----------------
 ld/testsuite/ld-loongarch-elf/macro_op.s           |  57 +-
 ld/testsuite/ld-loongarch-elf/macro_op_32.d        | 768 ++----------------
 ld/testsuite/ld-loongarch-elf/macro_op_32.s        |  43 +-
 ld/testsuite/ld-loongarch-elf/nopic-global-so.rd   |   5 +
 ld/testsuite/ld-loongarch-elf/nopic-global-so.sd   |  10 +
 ld/testsuite/ld-loongarch-elf/nopic-global.out     |   1 +
 ld/testsuite/ld-loongarch-elf/nopic-global.s       | 373 +++++++++
 ld/testsuite/ld-loongarch-elf/nopic-global.sd      |   5 +
 ld/testsuite/ld-loongarch-elf/nopic-global.xd      |   3 +
 ld/testsuite/ld-loongarch-elf/nopic-local.out      |   1 +
 ld/testsuite/ld-loongarch-elf/nopic-local.rd       |   0
 ld/testsuite/ld-loongarch-elf/nopic-local.s        | 383 +++++++++
 ld/testsuite/ld-loongarch-elf/nopic-local.sd       |   5 +
 ld/testsuite/ld-loongarch-elf/nopic-local.xd       |   3 +
 .../ld-loongarch-elf/nopic-weak-global-so.rd       |   5 +
 .../ld-loongarch-elf/nopic-weak-global-so.sd       |  10 +
 .../ld-loongarch-elf/nopic-weak-global.out         |   1 +
 ld/testsuite/ld-loongarch-elf/nopic-weak-global.s  | 374 +++++++++
 ld/testsuite/ld-loongarch-elf/nopic-weak-global.sd |   5 +
 ld/testsuite/ld-loongarch-elf/nopic-weak-global.xd |   3 +
 ld/testsuite/ld-loongarch-elf/nopic-weak-local.out |   1 +
 ld/testsuite/ld-loongarch-elf/nopic-weak-local.rd  |   0
 ld/testsuite/ld-loongarch-elf/nopic-weak-local.s   | 383 +++++++++
 ld/testsuite/ld-loongarch-elf/nopic-weak-local.sd  |   5 +
 ld/testsuite/ld-loongarch-elf/nopic-weak-local.xd  |   3 +
 ld/testsuite/ld-loongarch-elf/pic.exp              | 202 +++++
 ld/testsuite/ld-loongarch-elf/pic.ld               |  18 +
 51 files changed, 2949 insertions(+), 2443 deletions(-)

commit ff5a2f9d84b3689f4bca23a71a87170faa1c375d
Author: liuzhensong <liuzhensong@loongson.cn>
Date:   Wed Jul 20 19:55:27 2022 +0800

    bfd: Delete R_LARCH_NONE from dyn info of LoongArch.
    
      Some R_LARCH_64 in section .eh_frame will to generate
      R_LARCH_NONE, we change relocation to R_LARCH_32_PCREL
      from R_LARCH_64 in setction .eh_frame and not generate
      dynamic relocation for R_LARCH_32_PCREL.
    
      Add New relocate type R_LARCH_32_PCREL for .eh_frame.
    
      include/elf/
        loongarch.h
    
      bfd/
        bfd/bfd-in2.h
        libbfd.h
        reloc.c
        elfxx-loongarch.c
        elfnn-loongarch.c
    
      gas/config/
        tc-loongarch.c
    
      binutils/
        readelf.c
    
      ld/testsuite/ld-elf/
        eh5.d
    
    (cherry picked from commit 9801120721c3a702ce3bd50433ef920f92a83502)

 bfd/bfd-in2.h             |  1 +
 bfd/elfnn-loongarch.c     | 11 +++++++++++
 bfd/elfxx-loongarch.c     | 19 ++++++++++++++++++-
 bfd/libbfd.h              |  1 +
 bfd/reloc.c               |  3 +++
 binutils/readelf.c        |  2 ++
 include/elf/loongarch.h   |  5 ++++-
 ld/testsuite/ld-elf/eh5.d |  2 +-
 8 files changed, 41 insertions(+), 3 deletions(-)

commit f700a51b60cdf74f73e25b51e3c08516f0698b8d
Author: liuzhensong <liuzhensong@loongson.cn>
Date:   Fri Jul 15 16:07:48 2022 +0800

    LoongArch: Move ifunc info to rela.dyn from rela.plt.
    
      Delete R_LARCH_IRELATIVE from dynamic loader (glibc ld.so) when
      loading lazy function (rela.plt section).
    
      In dynamic programes, move ifunc dynamic relocate info to section
      srelgot from srelplt.
    
      bfd/
        elfnn-loongarch.c
    
    (cherry picked from commit bc2a35c0b48a93db21af2e7c429dc83828c672c8)

 bfd/elfnn-loongarch.c | 373 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 344 insertions(+), 29 deletions(-)

commit 5c3fd6b8310a8abcbe759af2f86f897111473f17
Author: liuzhensong <liuzhensong@loongson.cn>
Date:   Fri Jul 15 16:04:34 2022 +0800

    LoongArch: gas: Add new reloc types.
    
      Generate new relocate types while use new macro insns.
    
      gas/config/
        loongarch-lex.h
        loongarch-parse.y
        tc-loongarch.c
        tc-loongarch.h
    
    (cherry picked from commit f09482a8747b6fd4c2d59a6a64677d3a3fe1e092)

 gas/config/loongarch-lex.h   |   3 +
 gas/config/loongarch-parse.y |  72 ++++++----------------
 gas/config/tc-loongarch.c    | 140 +++++++++++++++++++++++++++++--------------
 gas/config/tc-loongarch.h    |   7 +--
 4 files changed, 120 insertions(+), 102 deletions(-)

commit cb01fe75e68abb308d8c753b4b0fed5a28cf839f
Author: liuzhensong <liuzhensong@loongson.cn>
Date:   Mon Jul 11 10:52:10 2022 +0800

    LoongArch:opcodes: Add new reloc types.
    
      opcodes: Replace old insns with news and generate new relocate types
      while macro insns expanding.
    
      opcodes/
        loongarch-opc.c
    
    (cherry picked from commit cbdbf445356c25521b606e30e5270f74e65011bc)

 opcodes/loongarch-opc.c | 412 ++++++++++++++++++++++++++++--------------------
 1 file changed, 242 insertions(+), 170 deletions(-)

commit 4b20400bfca671c3d115e4ce5e27c24da87826b2
Author: liuzhensong <liuzhensong@loongson.cn>
Date:   Mon Jul 11 15:11:03 2022 +0800

    bfd: Add supported for LoongArch new relocations.
    
      Define new reloc types according to linker needs.
    
      include/elf/
        loongarch.h
    
      bfd/
        bfd-in2.h
        libbfd.h
        reloc.c
        elfnn-loongarch.c
        elfxx-loongarch.c
        elfxx-loongarch.h
    
    (cherry picked from commit 6d13722a97cee3fd397e116bde3bcedbb1e220be)

 bfd/bfd-in2.h           |   36 ++
 bfd/elfnn-loongarch.c   | 1202 ++++++++++++++++++++++++++---------------
 bfd/elfxx-loongarch.c   | 1354 ++++++++++++++++++++++++++++++++++++-----------
 bfd/elfxx-loongarch.h   |    4 +
 bfd/libbfd.h            |   36 ++
 bfd/reloc.c             |   79 +++
 include/elf/loongarch.h |  136 +++++
 7 files changed, 2095 insertions(+), 752 deletions(-)

commit 82af4785071bfedf9ba35a694385a000dab113a5 (tag: gentoo/binutils-2.39-2)
Author: Andreas K. Hüttel <dilfridge@gentoo.org>
Date:   Sat Jul 31 01:18:18 2021 +0200

    Gentoo: XFAIL 15 broken ld.gold tests
    
    It seems like either the tests or ld.gold in general cannot handle
    compilers built with --enable-default-pie. No fix yet, so let's ignore
    these test failures for the moment. For details see the linked bugs.
    
    Bug: https://bugs.gentoo.org/684046
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=22755
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27303

 gold/testsuite/Makefile.am |  6 ++++++
 gold/testsuite/Makefile.in | 16 ++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

commit 6b16c2989b670673c61581ee97b98633bfaf0c5d
Author: Andreas K. Hüttel <dilfridge@gentoo.org>
Date:   Sat Jul 24 15:20:16 2021 +0200

    Gentoo: Give also libctf optionally a gentoo-specific soversion

 libctf/Makefile.am  | 14 +++++++++++++-
 libctf/Makefile.in  |  9 ++++++++-
 libctf/configure    | 35 +++++++++++++++++++++++++++++++++--
 libctf/configure.ac | 10 ++++++++++
 4 files changed, 64 insertions(+), 4 deletions(-)

commit 1a7d7f2439957b6f3d7d55386f6219acdaff3f6b
Author: Andreas K. Hüttel <dilfridge@gentoo.org>
Date:   Tue Jul 20 21:15:24 2021 +0200

    Gentoo: Pass --hash-style=sysv to ld in the testsuite

 binutils/testsuite/lib/binutils-common.exp |  2 +-
 ld/testsuite/lib/ld-lib.exp                | 16 ++++++++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)

commit 719a1f8e5c946472805130fb0a89886e66b52404
Author: Sergei Trofimovich <slyfox@gentoo.org>
Date:   Tue Jul 20 21:12:38 2021 +0200

    Gentoo: add --with-extra-soversion-suffix= option
    
    --with-extra-soversion-suffix= will allow Gentoo to
    distinct libbfd.so and libopcodes.so to have more precise
    SONAME.
    
    Today --enable-targets=all and --enable-64-bit-bfd change
    libbfd.so ABI:
    --enable-targets=all adds new symbols to the library
    --enable-64-bit-bfd modifies BFD_ARCH_SIZE default and
    changes sizes of integer parameters and fields to most
    APIs.
    
    --with-extra-soversion-suffix= will allow Gentoo to inject
    additional keys into SONAME to indicate ABI change and avoid
    hard to diagnose crashes when user reinstalls libbfd.so
    built with different flags (see https://bugs.gentoo.org/663690).
    
    Bug: https://bugs.gentoo.org/666100
    Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
    
    Ported to binutils 2.37 by Andreas K. Hüttel <dilfridge@gentoo.org>

 bfd/Makefile.am  |  5 +++++
 bfd/Makefile.in  |  4 ++++
 bfd/configure    | 13 +++++++++++++
 bfd/configure.ac |  7 +++++++
 4 files changed, 29 insertions(+)

commit 0665545051ab8774296889a724b4e227cc00955c
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Fri Jan 7 00:15:53 2005 -0500

    Gentoo: libiberty: install PIC version of libiberty.a
    
    This will install a PIC version of libiberty.a by overwriting the non-PIC
    version of libiberty.a while compiling.  We do this because there is no
    shared version of libiberty for random apps to link against which means if
    someone wants to use this in a shared library or PIE, they're out of luck.
    It's arguable whether people should be able to use this in a shared lib,
    but usage in PIE should be fine.  You could argue that this penalizes the
    non-PIE users, but the counter point is that people using this library in
    general are fairly low, and we'd rather have things work for all of them.
    
    (cherry picked from commit 112aff9ad3e2675556370c4281117a6df0a879d9)

 libiberty/Makefile.in | 1 +
 1 file changed, 1 insertion(+)

commit 1e57c8c5d594e927d2aaa4dda13f13b25decd289
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Tue Jul 20 21:08:31 2021 +0200

    Gentoo: gold/ld: add support for poisoned system directories
    
    This is based on the old CodeSourcery patch written by Joseph Myers to add
    support to the link for detecting & rejecting bad -L paths when using a
    cross-compiler.  The differences here:
    * The command line flags are always available.
    * We can turn on & off the warning via the command line.
    * The configure option controls the default warning behavior.
    * Add support for gold.
    
    It is not currently upstream, nor has it been submitted at all.  There are
    no plans to do so currently either.
    
    BUG=chromium:488360
    TEST=`cbuildbot chromiumos-sdk` passes  # tests arm/amd64/mipsel/x86
    TEST=`cbuildbot panther_moblab-full whirlwind-release` pass
    TEST=`cbuildbot {x32,arm64}-generic-full` has no new failures
    TEST=x86_64-cros-linux-gnu-ld throws warnings when using -L/lib (gold & bfd)
    
    Reviewed-on: https://chromium-review.googlesource.com/272083
    (cherry picked from commit f92dbf35c00ab13cee36f6be8ae5ca46454d9000)
    
    Ported to binutils 2.37 by Andreas K. Hüttel <dilfridge@gentoo.org>
    Ported to binutils 2.39 by WANG Xuerui <xen0n@gentoo.org>

 gold/options.cc | 33 +++++++++++++++++++++++++++++++++
 gold/options.h  |  7 +++++++
 ld/config.in    |  3 +++
 ld/configure    | 20 ++++++++++++++++++--
 ld/configure.ac | 10 ++++++++++
 ld/ld.h         |  7 +++++++
 ld/ld.texi      | 18 ++++++++++++++++++
 ld/ldfile.c     | 20 ++++++++++++++++++++
 ld/ldlex.h      |  3 +++
 ld/ldmain.c     |  7 +++++++
 ld/lexsup.c     | 24 ++++++++++++++++++++++++
 11 files changed, 150 insertions(+), 2 deletions(-)

commit 84110619ccc2bbb0ba5535f761cdea950b1db213
Author: Nick Clifton <nickc@redhat.com>
Date:   Fri Aug 5 14:02:43 2022 +0100

    reset development to true.  update version number
    
    Fixed to not touch files outside the release tarball- dilfridge

 bfd/configure                  |  20 +++---
 bfd/development.sh             |   2 +-
 bfd/po/bfd.pot                 | 156 ++++++++++++++++++++---------------------
 bfd/version.m4                 |   2 +-
 binutils/configure             |  20 +++---
 gas/configure                  |  20 +++---
 gprof/configure                |  20 +++---
 gprofng/configure              |  20 +++---
 gprofng/libcollector/configure |  20 +++---
 ld/configure                   |  20 +++---
 opcodes/configure              |  20 +++---
 opcodes/po/opcodes.pot         |   8 +--
 12 files changed, 164 insertions(+), 164 deletions(-)
