1. Jan 13, 2022
    • Alan Modra's avatar
      Re: gas: add visibility support using GNU syntax on XCOFF · 1ffce3f8
      Alan Modra authored
      tc-ppc.c: In function 'ppc_comm':
      tc-ppc.c:4560:40: error: 'visibility' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      
      With that fixed we hit lots of segfaults in the ld testsuite.
      
      	PR 22085
      bfd/
      	* xcofflink.c (xcoff_link_input_bfd): Don't segfault on NULL
      	sym_hash.
      gas/
      	* config/tc-ppc.c (ppc_comm): Init visibility.
      1ffce3f8
    • Alan Modra's avatar
      dt-relr.exp --no-as-needed · c39828d4
      Alan Modra authored
      Otherwise the very simple test may not be linked with libc.so at all,
      and thus correctly have no version reference added.  Causing failure
      of the dt-relr-glibc-1b.so test.
      
      	* testsuite/ld-elf/dt-relr.exp: Link with --no-as-needed.
      c39828d4
    • Alan Modra's avatar
      Correct .relr.dyn nocombreloc script · 34c95e6a
      Alan Modra authored
      	* scripttempl/elf.sc (.relr.dyn): Don't depend on $COMBRELOC.
      34c95e6a
    • Alan Modra's avatar
      testsuite supports_dt_relr · fb6ac163
      Alan Modra authored
      Tidy, and fix "FAIL: Build dt-relr-glibc-1b.so" on all non-x86
      linux targets.
      
      binutils/
      	* binutils-common.exp (supports_dt_relr): New proc.
      ld/
      	* testsuite/config/default.exp (DT_RELR_LDFLAGS, NO_DT_RELR_LDFLAGS),
      	(DT_RELR_CC_LDFLAGS, NO_DT_RELR_CC_LDFLAGS): Use supports_dt_relr.
      	* testsuite/ld-elf/dt-relr.exp: Don't run unless supports_dt_relr.
      	* testsuite/ld-elf/dt-relr-1a.d: Likewise.
      	* testsuite/ld-elf/dt-relr-1b.d: Likewise.
      	* testsuite/ld-elf/dt-relr-1c.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2a.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2b.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2c.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2d.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2e.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2f.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2g.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2h.d: Likewise.
      	* testsuite/ld-elf/dt-relr-3a.d: Likewise.
      	* testsuite/ld-elf/dt-relr-3b.d: Likewise.
      fb6ac163
    • Alan Modra's avatar
      Don't use C++ comments in assembly · dd68e156
      Alan Modra authored
      It might seem to work, but only if '/' is a start of comment char.
      
      	* testsuite/ld-elf/dt-relr-1.s: Use # for comment.
      	* testsuite/ld-elf/dt-relr-2.s: Likewise.
      	* testsuite/ld-elf/dt-relr-3.s: Likewise.
      dd68e156
    • Alan Modra's avatar
      Move DT_RELR tag setting to elflink.c · 9c3d7d9b
      Alan Modra authored
      This makes the code setting DT_RELR tags generally available.  Many
      targets will be able to use the defaults.  Those that can't should set
      up sh_entsize for .relr.dyn output section before reaching the dynamic
      tag code in bfd_elf_final_link.
      
      	* elflink.c (bfd_elf_final_link): Set up DT_RELR tags and sh_entsize.
      	* elfxx-x86.c (_bfd_x86_elf_finish_dynamic_sections): Don't do any
      	of that here.
      9c3d7d9b
    • Alan Modra's avatar
      Re: Set SEC_ELF_REVERSE_COPY earlier · 0ae12467
      Alan Modra authored
      Let's not rely on .init/.fini having relocs for the size sanity check.
      This is mainly to squash reports of "my fuzzed object made ld hang".
      0ae12467
    • Tiezhu Yang's avatar
      gdb: testsuite: make string[] type as char in gdb.base/charset.c · e31cf164
      Tiezhu Yang authored
      This reverts the commit ff656e2e
      
       ("gdb: testsuite: fix failed
      testcases in gdb.base/charset.exp").
      
      The original test code has no problem. On an architecture where
      char is signed, then both 'A' and ebcdic_us_string[7] will yield
      -63, which makes the equality true. On an architecture where char
      is unsigned, then both 'A' and ebcdic_us_string[7] will yield 193,
      which also makes the equality true.
      
      The test cases only failed on LoongArch. The default type of char
      is signed char on LoongArch, like x86-64. But when use gdb print
      command on LoongArch, the default type of char is unsigned char,
      this is wrong, I will look into it later, sorry for that.
      
      On LoongArch:
      
        $ cat test_char.c
        #include <stdio.h>
      
        int main()
        {
                char c1 = 193;
                unsigned char c2 = 193;
      
                printf("%d\n", c1);
                printf("%d\n", c1 == c2);
      
                return 0;
        }
        $ gcc test_char.c -o test_char
        $ ./test_char
        -63
        0
      
        (gdb) set target-charset EBCDIC-US
        (gdb) print 'A'
        $1 = 193 'A'
        (gdb) print /c 'A'
        $2 = 193 'A'
        (gdb) print /u 'A'
        $3 = 193
        (gdb) print /d 'A'
        $4 = -63
        (gdb) print /x 'A'
        $5 = 0xc1
      
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      e31cf164
    • GDB Administrator's avatar
      Automatic date update in version.in · cf6059a6
      GDB Administrator authored
      cf6059a6
    • Carl Love's avatar
      gdb Power 9 add test for HW watchpoint support. · 8d4e4d13
      Carl Love authored
      The Power 9 processor revision 2.2 has HW watchpoint support disabled due
      to a HW bug.  The support is fixed in Power 9 processor revision 2.3.  This
      patch add a test to lib/gdb.exp for Power to determine if the processor
      supports HW watchpoints or not.  If the Power processor doesn't support HW
      watchpoints the proceedure skip_hw_watchpoint_tests will return 1 to
      disable the various HW watchpoint tests.
      
      The patch has been tested on Power 9, processor revesions 2.2 and 2.3.  The
      patch has also been tested on Power 10.  No regression test failures were
      found.
      8d4e4d13
    • Andrew Burgess's avatar
      gdb/python: add gdb.host_charset function · 61671e97
      Andrew Burgess authored
      We already have gdb.target_charset and gdb.target_wide_charset.  This
      commit adds gdb.host_charset along the same lines.
      61671e97
  2. Jan 12, 2022
    • Tankut Baris Aktemur's avatar
      gdb/testsuite: fix gdb.python/py-events.exp for finding process id · 51eebae3
      Tankut Baris Aktemur authored
      When executed with --target_board=native-extended-gdbserver, the
      gdb.python/py-events.exp test errors out with
      
        ERROR: tcl error sourcing /path/to/gdb/testsuite/gdb.python/py-events.exp.
        ERROR: can't read "process_id": no such variable
            while executing
        "lappend expected "ptid: \\($process_id, $process_id, 0\\)" "address: $addr""
            (file "/path/to/gdb/testsuite/gdb.python/py-events.exp" line 103)
            invoked from within
        "source /path/to/gdb/testsuite/gdb.python/py-events.exp"
            ("uplevel" body line 1)
            invoked from within
        "uplevel #0 source /path/to/gdb/testsuite/gdb.python/py-events.exp"
            invoked from within
        "catch "uplevel #0 source $test_file_name""
      
      There are multiple problems around this:
      
      1. The process_id variable is not initialized to a default value.
      
      2. The test attempts to find the PID of the current thread, but the
         regexp that it uses is not tailored for the output printed by the
         remote target.
      
      3. The test uses "info threads" to find the current thread PID.
         Using the "thread" command instead is simpler.
      
      Fix these problems.
      51eebae3
    • Tom Tromey's avatar
      Don't mention "serial" in target remote description · ae9adb36
      Tom Tromey authored
      PR remote/9177 points out that "info files" mentions "serial" a couple
      of times:
      
          Remote serial target in gdb-specific protocol:
          Debugging a target over a serial line.
      
      However, often the remote target isn't really a serial connection.
      
      It seems to me that this text could be a bit clearer; and furthermore
      since "info files" prints the target's long description,
      remote_target::files_info doesn't really add much and can simply be
      removed.
      
      Regression tested on x86-64 Fedora 34.
      
      Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=9177
      
      ae9adb36
    • H.J. Lu's avatar
      ld: Add glibc dependency for DT_RELR · 72aa8173
      H.J. Lu authored
      When DT_RELR is enabled, to avoid random run-time crash with older glibc
      binaries without DT_RELR support, add a GLIBC_ABI_DT_RELR symbol version,
      which is provided by glibc with DT_RELR support, dependency on the shared
      C library if it provides a GLIBC_2.XX symbol version.
      
      bfd/
      
      	* elflink.c (elf_link_add_dt_relr_dependency): New function.
      	(bfd_elf_size_dynamic_sections): Call
      	elf_link_add_dt_relr_dependency if DT_RELR is enabled.
      
      ld/
      
      	* ld.texi: Mention GLIBC_ABI_DT_RELR in -z pack-relative-relocs
      	entry.
      	* testsuite/ld-elf/dt-relr-glibc-1.c: New file.
      	* testsuite/ld-elf/dt-relr-glibc-1a.rd: Likewise.
      	* testsuite/ld-elf/dt-relr-glibc-1b.rd: Likewise.
      	* testsuite/ld-elf/dt-relr.exp: Likewise.
      72aa8173
    • H.J. Lu's avatar
      ld: Add simple DT_RELR tests · 4d9e2e53
      H.J. Lu authored
      	* testsuite/ld-elf/dt-relr-1.s: New file.
      	* testsuite/ld-elf/dt-relr-1a.d: Likewise.
      	* testsuite/ld-elf/dt-relr-1b.d: Likewise.
      	* testsuite/ld-elf/dt-relr-1c.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2.s: Likewise.
      	* testsuite/ld-elf/dt-relr-2a.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2b.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2c.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2d.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2e.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2f.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2g.d: Likewise.
      	* testsuite/ld-elf/dt-relr-2h.d: Likewise.
      	* testsuite/ld-elf/dt-relr-3.s: Likewise.
      	* testsuite/ld-elf/dt-relr-3a.d: Likewise.
      	* testsuite/ld-elf/dt-relr-3b.d: Likewise.
      	* testsuite/ld-i386/dt-relr-1.s: Likewise.
      	* testsuite/ld-i386/dt-relr-1a.d: Likewise.
      	* testsuite/ld-i386/dt-relr-1b.d: Likewise.
      	* testsuite/ld-x86-64/dt-relr-1a-x32.d: Likewise.
      	* testsuite/ld-x86-64/dt-relr-1a.d: Likewise.
      	* testsuite/ld-x86-64/dt-relr-1b-x32.d: Likewise.
      	* testsuite/ld-x86-64/dt-relr-1b.d: Likewise.
      	* testsuite/ld-x86-64/dt-relr-1.s: Likewise.
      	* testsuite/ld-i386/i386.exp: Run dt-relr-1a and dt-relr-1b.
      	* testsuite/ld-x86-64/x86-64.exp: Run dt-relr-1a, dt-relr-1a-x32
      	dt-relr-1b and dt-relr-1b-x32.
      4d9e2e53
    • H.J. Lu's avatar
      x86: Add DT_RELR support · 5af6f000
      H.J. Lu authored
      DT_RELR is implemented with linker relaxation:
      
      1. During linker relaxation, we scan input relocations with the same
      logic in relocate_section to determine if a relative relocation should
      be generated and save the relative relocation candidate information for
      sizing the DT_RELR section later after all symbols addresses can be
      determined.  For these relative relocations which can't be placed in
      the DT_RELR section, they will be placed in the rela.dyn/rel.dyn
      section.
      2. When DT_RELR is enabled, _bfd_elf_map_sections_to_segments calls a
      backend function to size the DT_RELR section which will compute the
      DT_RELR section size and tell ldelf_map_segments to layout sections
      again when the DT_RELR section size has been increased.
      3. After regular symbol processing is finished, bfd_elf_final_link calls
      a backend function to finish the DT_RELR section.
      
      	* elf32-i386.c (elf_i386_relocate_section): Don't generate
      	relative relocation when DT_RELR is enabled.
      	(elf_i386_finish_dynamic_symbol): Likewise.
      	* elf64-x86-64.c (elf_x86_64_relocate_section): Don't generate
      	relative relocation when DT_RELR is enabled.
      	(elf_x86_64_finish_dynamic_symbol): Likewise.
      	* elfxx-x86.c (_bfd_x86_elf_link_hash_table_create): Initialize
      	relative_r_type, relative_r_name, elf_append_reloc,
      	elf_write_addend and elf_write_addend_in_got.
      	(elf_x86_relative_reloc_record_add): New function.
      	(_bfd_x86_elf_link_relax_section): Likewise.
      	(elf64_dt_relr_bitmap_add): Likewise.
      	(elf32_dt_relr_bitmap_add): Likewise.
      	(_bfd_elf32_write_addend): Likewise.
      	(_bfd_elf64_write_addend): Likewise.
      	(elf_x86_size_or_finish_relative_reloc): Likewise.
      	(elf_x86_compute_dl_relr_bitmap): Likewise.
      	(elf_x86_write_dl_relr_bitmap): Likewise.
      	(elf_x86_relative_reloc_compare ): Likewise.
      	(_bfd_elf_x86_size_relative_relocs): Likewise.
      	(_bfd_elf_x86_finish_relative_relocs): Likewise.
      	(_bfd_x86_elf_size_dynamic_sections): Skip the .relr.dyn section.
      	(_bfd_x86_elf_finish_dynamic_sections): Convert 3 spare dynamic
      	tags to DT_RELR, DT_RELRSZ and for compact relative relocation.
      	* elfxx-x86.h (X86_64_GOT_TYPE_P): New.
      	(I386_GOT_TYPE_P): Likewise.
      	(X86_GOT_TYPE_P): Likewise.
      	(X86_64_RELATIVE_RELOC_TYPE_P): Likewise.
      	(I386_RELATIVE_RELOC_TYPE_P): Likewise.
      	(X86_RELATIVE_RELOC_TYPE_P): Likewise.
      	(X86_LOCAL_GOT_RELATIVE_RELOC_P): Likewise.
      	(I386_PCREL_TYPE_P): Likewise.
      	(X86_64_PCREL_TYPE_P): Likewise.
      	(X86_64_NEED_DYNAMIC_RELOC_TYPE_P): Rewrite.
      	(I386_NEED_DYNAMIC_RELOC_TYPE_P): Likewise.
      	(GENERATE_DYNAMIC_RELOCATION_P): Also check rel_from_abs.
      	(elf_x86_link_hash_entry): Add got_relative_reloc_done.
      	(elf_x86_relative_reloc_record): New.
      	(elf_x86_relative_reloc_data): Likewise.
      	(elf_dt_relr_bitmap): Likewise.
      	(elf_x86_link_hash_table): Add dt_relr_bitmap, relative_reloc,
      	unaligned_relative_reloc, relative_r_type, relative_r_name,
      	elf_append_reloc, elf_write_addend, elf_write_addend_in_got and
      	relative_reloc_done.
      	(elf_x86_relative_reloc_done): New.
      	(relative_reloc_packed): Likewise.
      	(_bfd_x86_elf_link_relax_section): Likewise.
      	(_bfd_elf_x86_size_relative_relocs): Likewise.
      	(_bfd_elf_x86_finish_relative_relocs): Likewise.
      	(_bfd_elf32_write_addend): Likewise.
      	(_bfd_elf64_write_addend): Likewise.
      	(bfd_elf32_bfd_relax_section): Likewise.
      	(bfd_elf64_bfd_relax_section): Likewise.
      	(elf_backend_size_relative_relocs): Likewise.
      	(elf_backend_finish_relative_relocs): Likewise.
      	(elf_x86_allocate_local_got_info): Also allocate
      	relative_reloc_done.
      5af6f000
    • H.J. Lu's avatar
      elf: Support DT_RELR in linker tests · f2e37a5c
      H.J. Lu authored
      Allow eabling and disabling DT_RELR in linker tests.  Disable DT_RELR in
      linker tests which don't expect DT_RELR in linker outputs.
      
      binutils/
      
      	* testsuite/lib/binutils-common.exp (run_dump_test): Make
      	DT_RELR_LDFLAGS and NO_DT_RELR_LDFLAGS global.
      
      ld/
      
      	* testsuite/config/default.exp (DT_RELR_LDFLAGS): New.
      	(DT_RELR_CC_LDFLAGS): Likewise.
      	(NO_DT_RELR_LDFLAGS): Likewise.
      	(NO_DT_RELR_CC_LDFLAGS): Likewise.
      	* testsuite/ld-elf/shared.exp: Pass $NO_DT_RELR_LDFLAGS to
      	linker for some tests.
      	* testsuite/ld-i386/export-class.exp: Likewise.
      	* testsuite/ld-i386/i386.exp: Likewise.
      	* testsuite/ld-i386/ibt-plt-2a.d: Pass $NO_DT_RELR_LDFLAGS to
      	linker.
      	* testsuite/ld-i386/ibt-plt-3a.d: Likewise.
      	* testsuite/ld-i386/ibt-plt-3c.d: Likewise.
      	* testsuite/ld-i386/pr26869.d: Likewise.
      	* testsuite/ld-i386/report-reloc-1.d: Likewise.
      	* testsuite/ld-ifunc/ifunc-2-i386-now.d: Likewise.
      	* testsuite/ld-ifunc/ifunc-2-local-i386-now.d: Likewise.
      	* testsuite/ld-ifunc/ifunc-2-local-x86-64-now.d: Likewise.
      	* testsuite/ld-ifunc/ifunc-2-x86-64-now.d: Likewise.
      	* testsuite/ld-ifunc/pr17154-x86-64.d: Likewise.
      	* testsuite/ld-x86-64/bnd-branch-1-now.d: Likewise.
      	* testsuite/ld-x86-64/bnd-ifunc-1-now.d: Likewise.
      	* testsuite/ld-x86-64/bnd-ifunc-2-now.d: Likewise.
      	* testsuite/ld-x86-64/bnd-ifunc-2.d: Likewise.
      	* testsuite/ld-x86-64/bnd-plt-1-now.d: Likewise.
      	* testsuite/ld-x86-64/bnd-plt-1.d: Likewise.
      	* testsuite/ld-x86-64/ibt-plt-2a-x32.d: Likewise.
      	* testsuite/ld-x86-64/ibt-plt-2a.d: Likewise.
      	* testsuite/ld-x86-64/ibt-plt-3a-x32.d: Likewise.
      	* testsuite/ld-x86-64/ibt-plt-3a.d: Likewise.
      	* testsuite/ld-x86-64/ilp32-4.d: Likewise.
      	* testsuite/ld-x86-64/load1c.d: Likewise.
      	* testsuite/ld-x86-64/load1d.d: Likewise.
      	* testsuite/ld-x86-64/pr13082-2b.d: Likewise.
      	* testsuite/ld-x86-64/pr14207.d: Likewise.
      	* testsuite/ld-x86-64/pr18176.d: Likewise.
      	* testsuite/ld-x86-64/pr19162.d: Likewise.
      	* testsuite/ld-x86-64/pr19636-2d.d: Likewise.
      	* testsuite/ld-x86-64/pr19636-2l.d: Likewise.
      	* testsuite/ld-x86-64/pr20253-1d.d: Likewise.
      	* testsuite/ld-x86-64/pr20253-1f.d: Likewise.
      	* testsuite/ld-x86-64/pr20253-1j.d: Likewise.
      	* testsuite/ld-x86-64/pr20253-1l.d: Likewise.
      	* testsuite/ld-x86-64/report-reloc-1-x32.d: Likewise.
      	* testsuite/ld-x86-64/report-reloc-1.d: Likewise.
      	* testsuite/ld-x86-64/export-class.exp (x86_64_export_class_test):
      	Pass $NO_DT_RELR_LDFLAGS to linker.
      	* testsuite/ld-x86-64/x86-64.exp: Pass $NO_DT_RELR_LDFLAGS to
      	linker for some tests.
      f2e37a5c
    • H.J. Lu's avatar
      elf: Add size_relative_relocs and finish_relative_relocs · 23cc1de5
      H.J. Lu authored
      On some targets, the DT_RELR section size can be computed only after all
      symbols addresses can be determined.  Set the preliminary DT_RELR section
      size before mapping sections to segments and set the final DT_RELR section
      size after regular symbol processing is done.
      
      	* elf-bfd.h (elf_backend_data): Add size_relative_relocs and
      	finish_relative_relocs.
      	* elf.c (_bfd_elf_map_sections_to_segments): Call
      	size_relative_relocs if DT_RELR is enabled.
      	* elflink.c (bfd_elf_final_link): Call finish_relative_relocs
      	after regular symbol processing is finished if DT_RELR is enabled.
      	* elfxx-target.h (elf_backend_size_relative_relocs): New.
      	(elf_backend_finish_relative_relocs): Likewise.
      	(elfNN_bed): Add elf_backend_size_relative_relocs and
      	elf_backend_finish_relative_relocs.
      23cc1de5
    • H.J. Lu's avatar
      ld: Initial DT_RELR support · 6a91be86
      H.J. Lu authored
      Add a -z pack-relative-relocs option to enable DT_RELR and create a
      relr.dyn section for DT_RELR.  DT_RELR is implemented with the linker
      relaxation infrastructure, but it doesn't require the --relax option
      enabled.  -z pack-relative-relocs implies -z combreloc.  -z nocombreloc
      implies -z nopack-relative-relocs.
      
      -z pack-relative-relocs is chosen over the similar option in lld,
      --pack-dyn-relocs=relr, to implement a glibc binary lockout mechanism
      with a special glibc version symbol, to avoid random crashes of DT_RELR
      binaries with the existing glibc binaries.
      
      bfd/
      
      	* elf-bfd.h (elf_link_hash_table): Add srelrdyn.
      	* elflink.c (_bfd_elf_link_create_dynamic_sections): Create a
      	.relr.dyn section for DT_RELR.
      
      include/
      
      	* bfdlink.h (bfd_link_info): Add enable_dt_relr.
      
      ld/
      
      	* News: Mention -z pack-relative-relocs and
      	-z nopack-relative-relocs.
      	* ld.texi: Document -z pack-relative-relocs and
      	-z nopack-relative-relocs.
      	* ldelf.c (ldelf_after_parse): Disable DT_RELR if not building
      	PIE nor shared library.  Add 3 spare dynamic tags for DT_RELR,
      	DT_RELRSZ and DT_RELRENT.
      	* ldlang.c (lang_relax_sections): Also enable relaxation if
      	DT_RELR is enabled.
      	* emulparams/elf32_x86_64.sh: Source dt-relr.sh.
      	* emulparams/elf_i386.sh: Likewise.
      	* emulparams/elf_x86_64.sh: Likewise.
      	* emulparams/dt-relr.sh: New file.
      	* scripttempl/elf.sc: Support .relr.dyn.
      6a91be86
    • H.J. Lu's avatar
      elf: Pass need_layout to _bfd_elf_map_sections_to_segments · e2cbf4df
      H.J. Lu authored
      On some targets, the DT_RELR section size can be computed only after all
      symbols addresses can be determined.  Update ldelf_map_segments to pass
      need_layout to _bfd_elf_map_sections_to_segments which will size DT_RELR
      section and set need_layout to true if the DT_RELR section size is changed.
      
      bfd/
      
      	* elf-bfd.h (_bfd_elf_map_sections_to_segments): Add a bool
      	pointer argument.
      	* elf.c (_bfd_elf_map_sections_to_segments): Add a bool pointer
      	argument to indicate if section layout needs update.
      	(assign_file_positions_for_load_sections): Pass NULL to
      	_bfd_elf_map_sections_to_segments.
      	* elflink.c (_bfd_elf_strip_zero_sized_dynamic_sections): Pass
      	NULL to _bfd_elf_map_sections_to_segments.
      
      ld/
      
      	* ldelfgen.c (ldelf_map_segments): Pass &need_layout to
      	_bfd_elf_map_sections_to_segments.
      e2cbf4df
    • H.J. Lu's avatar
      elf: Add .relr.dyn to special_sections_r · fc07cf22
      H.J. Lu authored
      	* elf.c (special_sections_r): Add .relr.dyn.
      fc07cf22
    • Andrew Burgess's avatar
      gdb: add 'maint set/show gnu-source-highlight enabled' command · 643b1268
      Andrew Burgess authored
      In a later commit I want to address an issue with the Python pygments
      based code styling solution.  As this approach is only used when the
      GNU Source Highlight library is not available, testing bugs in this
      area can be annoying, as it requires GDB to be rebuilt with use of GNU
      Source Highlight disabled.
      
      This commit adds a pair of new maintenance commands:
      
        maintenance set gnu-source-highlight enabled on|off
        maintenance show gnu-source-highlight enabled
      
      these commands can be used to disable use of the GNU Source Highlight
      library, allowing me, in a later commit, to easily test bugs that
      would otherwise be masked by GNU Source Highlight being used.
      
      I made this a maintenance command, rather than a general purpose
      command, as it didn't seem like this was something a general user
      would need to adjust.  We can always convert the maintenance command
      to a general command later if needed.
      
      There's no test for this here, but this feature will be used in a
      later commit.
      643b1268
    • Andrew Burgess's avatar
      gdb: erase items from the source_cache::m_offset_cache · 0e42221a
      Andrew Burgess authored
      The source_cache class has two member variables m_source_map, which
      stores the file contents, and m_offset_cache, which stores offsets
      into the file contents.
      
      As source files are read the contents of the file, as well as the
      offset data, are stored in the cache using these two member variables.
      
      Whenever GDB needs either the files contents, or the offset data,
      source_cache::ensure is called.  This function looks for the file in
      m_source_map, and if it's found then this implies the file is also in
      m_offset_cache, and we're done.
      
      If the file is not in m_source_map then GDB calls
      source_cache::get_plain_source_lines to open the file and read its
      contents.  ::get_plain_source_lines also calculates the offset data,
      which is then inserted into m_offset_cache.
      
      Back in ::ensure, the file contents are added into m_source_map.  And
      finally, if m_source_map contains more than MAX_ENTRIES, an entry is
      removed from m_source_map.
      
      The problem is entries are not removed from m_offset_cache at the same
      time.
      
      This means that if a program contains enough source files, GDB will
      hold at most MAX_ENTRIES cached source file contents, but can contain
      offsets data for every source file.
      
      Now, the offsets data is going to be smaller than the cached file
      contents, so maybe there's no harm here.  But, when we reload the file
      contents we always recalculate the offsets data.  And, when we
      ::get_line_charpos asking for offset data we still call ::ensure which
      will ends up loading and caching the file contents.
      
      So, given the current code does the work of reloading the offset data
      anyway, we may as well save memory by capping m_offset_cache to
      MAX_ENTRIES just like we do m_source_map.
      
      That's what this commit does.
      
      There should be no user visible changes after this commit, except for
      ever so slightly lower memory usage in some cases.
      0e42221a
    • Andrew Burgess's avatar
      gdb: new 'maint flush source-cache' command · 39370778
      Andrew Burgess authored
      This commit adds a new 'maint flush source-cache' command, this
      flushes the cache of source file contents.
      
      After flushing GDB is forced to reread source files the next time any
      source lines are to be displayed.
      
      I've added a test for this new feature.  The test is a little weird,
      in that it modifies a source file after compilation, and makes use of
      the cache flush so that the changes show up when listing the source
      file.  I'm not sure when such a situation would ever crop up in real
      life, but maybe we can imagine such cases.
      
      In reality, this command is useful for testing the syntax highlighting
      within GDB, we can adjust the syntax highlighting settings, flush the
      cache, and then get the file contents re-highlighted using the new
      settings.
      39370778
    • Andrew Burgess's avatar
      gdb: rename lin-lwp to linux-nat in set/show debug · 8864ef42
      Andrew Burgess authored
      Rename 'set debug lin-lwp' to 'set debug linux-nat' and 'show debug
      lin-lwp' to 'show debug linux-nat'.
      
      I've updated the documentation and help text to match, as well as
      making it clear that the debug that is coming out relates to all
      aspects of Linux native inferior support, not just the LWP aspect of
      it.
      
      The boundary between general "native" target debug, and the lwp
      specific part of that debug was always a little blurry, but the actual
      debug variable inside GDB is debug_linux_nat, and the print routine
      linux_nat_debug_printf, is used throughout the linux-nat.c file, not
      just for lwp related debug, so the new name seems to make more sense.
      8864ef42
    • Clément Chigot's avatar
      ld: add hidden and internal visibility support for XCOFF · a8bc481f
      Clément Chigot authored
      This patch adds a primary support for hidden and internal visibility in
      GNU linker for XCOFF format.
      The protected visibility isn't yet supported.
      
      PR 22085
      
      bfd/ChangeLog:
      
      	* xcofflink.c (xcoff_dynamic_definition_p): Add hidden
      	  and internal visibility support.
      	(xcoff_link_add_symbols): Likewise.
      	(xcoff_auto_export_p): Likewise.
      	(bfd_xcoff_export_symbol): Likewise.
      	(xcoff_link_input_bfd): Likewise.
      
      ld/ChangeLog:
      
      	* testsuite/ld-vsb/main.c: Adapt for XCOFF.
      	* testsuite/ld-vsb/sh1.c: Likewse.
      	* testsuite/ld-vsb/vsb.exp: Likewise.
      	* testsuite/ld-vsb/visibility-1-xcoff-32.d: New test.
      	* testsuite/ld-vsb/visibility-1-xcoff-64.d: New test.
      	* testsuite/ld-vsb/visibility-2-xcoff-32.d: New test.
      	* testsuite/ld-vsb/visibility-2-xcoff-64.d: New test.
      	* testsuite/ld-vsb/xcoffvsb.dat: New test.
      a8bc481f
    • Clément Chigot's avatar
      ld/testsuite: prepare ld-elfvsb to support XCOFF · 59e31fd7
      Clément Chigot authored
      A following patch will add visibility support in ld for XCOFF. Thus,
      ld-elfvsb is renamed ld-vsb and a suffix is added to files targeting only
      ELF format.
      
      ld/ChangeLog:
      
      	* testsuite/ld-elfvsb: rename as ld-vsb.
      	* testsuite/ld-elfvsb/hidden0.d: move to ld-vsb and rename with
      	  suffix -elf.d.
      	* testsuite/ld-elfvsb/hidden1.d: Likewise.
      	* testsuite/ld-elfvsb/hidden2.d: Likewise.
      	* testsuite/ld-elfvsb/internal0.d: Likewise.
      	* testsuite/ld-elfvsb/internal1.d: Likewise.
      	* testsuite/ld-elfvsb/protected0.d: Likewise.
      	* testsuite/ld-elfvsb/protected1.d: Likewise.
      59e31fd7
    • Clément Chigot's avatar
      gas: add visibility support using GNU syntax on XCOFF · 09d4578f
      Clément Chigot authored
      In order to ease port of GNU assembly code and especially ld testsuite,
      this patch allows XCOFF to accept the usual GNU syntax for visibility.
      
      PR 22085
      
      gas/ChangeLog:
      
      	* config/tc-ppc.c (ppc_GNU_visibility): New function.
      	* testsuite/gas/ppc/aix.exp: Add new tests.
      	* testsuite/gas/ppc/xcoff-visibility-2-32.d: New test.
      	* testsuite/gas/ppc/xcoff-visibility-2-64.d: New test.
      	* testsuite/gas/ppc/xcoff-visibility-2.s: New test.
      09d4578f
    • Clément Chigot's avatar
      gas: add visibility support for XCOFF · add588a8
      Clément Chigot authored
      XCOFF assembly defines the visibility using an additional argument
      on several pseudo-ops: .globl, .weak, .extern and .comm.
      This implies that .globl and .weak syntax is different than the
      usual GNU syntax. But we want to provide compatibility with AIX
      assembler, especially because GCC is generating the visibility
      using this XCOFF syntax.
      
      PR 22085
      
      bfd/ChangeLog:
      
              * coffcode.h (coff_write_object_contents): Change XCOFF header
              vstamp field to 2.
              * coffgen.c (coff_print_symbol): Increase the size for n_type.
      
      gas/ChangeLog:
      
              * config/tc-ppc.c (ppc_xcoff_get_visibility): New function.
              (ppc_globl): New function.
              (ppc_weak): New function.
              (ppc_comm): Add visibility field support.
              (ppc_extern): Likewise.
              * testsuite/gas/all/cofftag.d: Adjust to new n_type size
              providing by objdump.
              * testsuite/gas/ppc/test1xcoff32.d: Likewise.
              * testsuite/gas/ppc/aix.exp: Add new tests.
              * testsuite/gas/ppc/xcoff-visibility-1-32.d: New test.
              * testsuite/gas/ppc/xcoff-visibility-1-64.d: New test.
              * testsuite/gas/ppc/xcoff-visibility-1.s: New test.
      
      include/ChangeLog:
      
              * coff/internal.h (SYM_V_INTERNAL, SYM_V_HIDDEN,
              SYM_V_PROTECTED, SYM_V_EXPORTED, SYM_V_MASK): New defines.
              * coff/xcoff.h (struct xcoff_link_hash_entry): Add visibility
              field.
      
      ld/ChangeLog:
      
              * testsuite/ld-pe/pr19803.d: Adjust to new n_type size
              providing by objdump.
      add588a8
    • Hans-Peter Nilsson's avatar
      objdump, readelf: Emit "CU:" format only when wide output is requested · c4f58714
      Hans-Peter Nilsson authored
      As pre-approved by Alan in
      https://sourceware.org/pipermail/binutils/2021-September/118019.html
      and I believe people have run into getting testsuite failures for
      test-environments with "long" directory names, at least once more
      since that time.  Enough.  I grepped the gas, binutils and ld
      testsuites for "CU:" to catch target-specific occurrences, but I
      noticed none.  I chose to remove "CU:" on the objdump tests instead of
      changing options to get the wide format, so as to keep the name of the
      test consistent with actual options; but added it to the readelf
      options for the gas test as I believe the "CU:" format is preferable.
      
      Tested for cris-elf and native x86_64-pc-linux-gnu.
      
      binutils:
      	* dwarf.c (display_debug_lines_decoded): Don't check the
      	string length of the directory, instead emit the "CU: dir/name"
      	format only if wide output is requested.
      	* testsuite/binutils-all/dw5.W, testsuite/binutils-all/objdump.WL:
      	Adjust accordingly.
      
      gas:
      	* testsuite/gas/elf/dwarf-5-loc0.d: Add -W to readelf options.
      c4f58714
    • Alan Modra's avatar
      Set SEC_ELF_REVERSE_COPY earlier · b02db378
      Alan Modra authored
      For the sake of DT_RELR.
      
      bfd/
      	* elflink.c (elf_link_input_bfd): Don't set SEC_ELF_REVERSE_COPY
      	here.  Move sanity checks to reverse copying code.
      ld/
      	* ldlang.c (lang_add_section): Set SEC_ELF_REVERSE_COPY for
      	.ctors/.dtors in .init_array/.fini_array.
      b02db378
    • Tiezhu Yang's avatar
      gdb: testsuite: fix wrong comment in gdb.base/charset.c · 295114a6
      Tiezhu Yang authored
      
      
      In gdb/testsuite/gdb.base/charset.c, use "IBM1047" instead of "EBCDIC"
      to fix the wrong comment.
      
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      295114a6
    • Tiezhu Yang's avatar
      gdb: testsuite: fix failed testcases in gdb.base/charset.exp · ff656e2e
      Tiezhu Yang authored
      
      
      In gdb/testsuite/gdb.base/charset.c, the last argument is greater than 127
      when call fill_run() in EBCDIC-US and IBM1047, but the type of string[] is
      char, this will change the value due to sign extension.
      
      For example, ebcdic_us_string[7] will be -63 instead of the original 193 in
      EBCDIC-US.
      
      Make the type of string[] as unsigned char to fix the following six failed
      testcases:
      
        $ grep FAIL gdb/testsuite/gdb.sum
        FAIL: gdb.base/charset.exp: check value of parsed character literal in EBCDIC-US
        FAIL: gdb.base/charset.exp: check value of parsed string literal in EBCDIC-US
        FAIL: gdb.base/charset.exp: check value of escape that doesn't exist in EBCDIC-US
        FAIL: gdb.base/charset.exp: check value of parsed character literal in IBM1047
        FAIL: gdb.base/charset.exp: check value of parsed string literal in IBM1047
        FAIL: gdb.base/charset.exp: check value of escape that doesn't exist in IBM1047
      
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      ff656e2e
    • GDB Administrator's avatar
      Automatic date update in version.in · e66b7536
      GDB Administrator authored
      e66b7536
    • Fangrui Song's avatar
      ar: Add --thin for creating thin archives · d1b69c50
      Fangrui Song authored
      In many ar implementations (FreeBSD, elfutils, etc), -T has the X/Open
      System Interface specified semantics. Therefore -T for thin archives is
      not recommended for portability. -T is deprecated without diagnostics.
      
          PR binutils/28759
          * ar.c (long_options): Add --thin.
          (usage) Add --thin. Deprecate -T without diagnostics.
          * doc/binutils.texi: Add doc.
          * NEWS: Mention --thin.
          * binutils/testsuite/binutils-all/ar.exp: Add tests.
      d1b69c50
  3. Jan 11, 2022
    • Martin Storsj's avatar
      Fix multiple problems with DLL generation. · c4a8df19
      Martin Storsj authored
      ld	* pe-dll.c (make_head): Prefix the symbol name with the dll name.
      	(make_tail, make_one, make_singleton_name_thunk): Likewise.
      	(make_import_fixup_entry, make_runtime_pseudo_reloc): Likewise.
      	(pe_create_runtime_relocator_reference): Likewise.
      	(pe_dll_generate_implib): Set dll_symname_len.
      	(pe_process_import_defs): Likewise.
      
      binutils
      	* dlltool.c (main): If a prefix has not been provided, attempt to
      	use a deterministic one based upon the dll name.
      c4a8df19
    • Jan Beulich's avatar
      gas/doc: mention quoted symbol names · d02f2788
      Jan Beulich authored
      d02f2788
    • Andrew Burgess's avatar
      gdbsupport: regenerate Makefile.in · 9ed5be56
      Andrew Burgess authored
      I had cause to regenerate gdbsupport/Makefile.in, and noticed some
      unexpected changes in the copyright header dates.
      
      I suspect that this was caused by the end of year date range update
      process.
      
      The Makefile.in contains two date ranges.  The first range appears to
      be the date range for the version of automake being used, that is the
      range runs up to 2017 only, when automake 1.15.1 was released.
      
      The second date range in Makefile.in represents the date range for the
      generated file, and so, now runs up to 2022.
      
      Anyway, this is the result of running autoreconf (using automake
      1.15.1) in the gdbsupport directory.
      9ed5be56
    • GDB Administrator's avatar
      Automatic date update in version.in · 892c10d3
      GDB Administrator authored
      892c10d3
  4. Jan 10, 2022
    • Clément Chigot's avatar
      XCOFF: add support for TLS relocations on hidden symbols · 3c503824
      Clément Chigot authored
      This patch adds support for TLS relocation targeting C_HIDEXT symbols.
      In gas, TLS relocations, except R_TLSM and R_TLMSL, must keep the value
      of their target symbol.
      In ld, it simply ensures that internal TLS symbols are added to the
      linker hash table for xcoff_reloc_type_tls.
      
      It also improves the tests made by both.
      
      bfd/ChangeLog:
      
      	* coff-rs6000.c (xcoff_howto_table): Fix name of R_TLSML.
      	(xcoff_reloc_type_tls): Replace the error when h is NULL by
      	an assert.
      	(xcoff_complain_overflow_unsigned_func): Adjust comments.
      	* coff64-rs6000.c (xcoff64_howto_table): Fix name of R_TLSML.
      	* xcofflink.c (xcoff_link_add_symbols_to_hash_table): New
      	function.
      	(xcoff_link_add_symbols): Add C_HIDEXT TLS symbols to the linker
      	hash table.
      
      gas/ChangeLog:
      
      	* config/tc-ppc.c (md_apply_fix): Enable support for TLS
      	relocation over internal symbols.
      	* testsuite/gas/ppc/aix.exp: Replace xcoff-tlms by xcoff-tls.
      	* testsuite/gas/ppc/xcoff-tlsm-32.d: Removed.
      	* testsuite/gas/ppc/xcoff-tlsm-64.d: Removed.
      	* testsuite/gas/ppc/xcoff-tlsm.s: Removed.
      	* testsuite/gas/ppc/xcoff-tls-32.d: New test.
      	* testsuite/gas/ppc/xcoff-tls-64.d: New test.
      	* testsuite/gas/ppc/xcoff-tls.s: New test.
      
      ld/ChangeLog:
      
      	* testsuite/ld-powerpc/aix52.exp: Improve aix-tls-reloc test.
      	* testsuite/ld-powerpc/aix-tls-reloc.s: Likewise.
      	* testsuite/ld-powerpc/aix-tls-reloc-32.d: Removed.
      	* testsuite/ld-powerpc/aix-tls-reloc-64.d: Removed.
      	* testsuite/ld-powerpc/aix-tls-reloc-32.dd: New test.
      	* testsuite/ld-powerpc/aix-tls-reloc-32.dt: New test.
      	* testsuite/ld-powerpc/aix-tls-reloc-64.dd: New test.
      	* testsuite/ld-powerpc/aix-tls-reloc-64.dt: New test.
      3c503824