aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-06-01Harden PowerPC64 OPD handling against fuzzersAlan Modra1-27/+60
PowerPC64 ELFv1 object files should have at most one .opd section, and OPD handling in elf64-ppc.c makes use of this fact by caching some .opd section info in the per-object bfd.tdata. This was done to avoid another word in the target specific section data. Of course, fuzzers don't respect the ABI, and even non-malicious users can accidentally create multiple .opd sections. So it is better to avoid possible buffer overflows and other confusion when OPD handling for a second .opd section references data for the first .opd section, by keeping the data per-section. The patch also fixes a memory leak, and a corner case where I think we could hit an assertion in opd_entry_value or read out of bounds in ppc64_elf_branch_reloc doing a final link producing non-ppc64 output. (It's a really rare corner case because not only would you need to be linking ppc64 objects to non-ppc64 output, you'd also need a branch reloc symbol to be defined in a .opd section of a non-ppc64 input.) * elf64-ppc.c (is_ppc64_elf): Move earlier in file. (ppc64_elf_branch_reloc): Check symbol bfd before accessing ppc64 elf specific data structures. (struct ppc64_elf_obj_tdata): Move opd union.. (struct _ppc64_elf_section_data): ..to here. (ppc64_elf_before_check_relocs): Allow for opd sec_type already set to sec_opd. (ppc64_elf_check_relocs): Only set sec_type to sec_toc when unset. Error for unexpected toc relocs. (opd_entry_value): Return -1 when non-ppc64 rather than asserting. Check and set sec_type too. Adjust for changed location of contents and relocs. (ppc64_elf_relocate_section): Adjust for changed location of cached .opd relocs. (ppc64_elf_free_cached_info): New function. (bfd_elf64_bfd_free_cached_info): Define.
2023-06-01bfd_close and target free_cached_memoryAlan Modra3-15/+9
bfd_free_cached_info is used in just one place in archive.c, which means most times we reach bfd_close the function isn't called. On the other hand, if bfd_free_cached_info is called we can't do much on the bfd since it loses all its obj_alloc memory. This restricts what can be done in a target _close_and_cleanup. In particular you can't look at sections, which leads to duplication of code in target close_and_cleanup and free_cached_info, eg. elfnn-aarch64.c. * opncls.c (_bfd_delete_bfd): Call bfd_free_cached_info. * elfnn-aarch64.c (elfNN_aarch64_close_and_cleanup): Delete. (bfd_elfNN_close_and_cleanup): Don't define. * som.c (som_bfd_free_cached_info): Don't call _bfd_generic_close_and_cleanup here. (som_close_and_cleanup): Define as _bfd_generic_close_and_cleanup.
2023-06-01section_by_target_index memory leakAlan Modra4-7/+28
The rs6000 backend can call coff_section_from_bfd_index from its object_p function via coff_set_alignment_hook. If the object doesn't match, or another target matches too, then the hash table needs to be freed via a cleanup. * coffgen.c (coff_object_cleanup): New function. (coff_real_object_p): Return coff_object_cleanup, and call on failure path. Move declaration to.. * libcoff-in.h: ..here. (coff_object_cleanup): Declare. * coff-stgo32.c (go32exe_cleanup): Call coff_object_cleanup. (go32exe_check_format): Adjust assertion. * libcoff.h: Regenerate.
2023-06-01Remove BFD_FAIL in cpu-sh.cAlan Modra1-6/+0
The assertions in cpu-sh.c can be triggered by passing bogus values in disassemble_info.mach. This doesn't cause any bfd misbehaviour. * cpu-sh.c (sh_get_arch_from_bfd_mach): Remove BFD_FAIL. (sh_get_arch_up_from_bfd_mach): Likewise.
2023-06-01Automatic date update in version.inGDB Administrator1-1/+1
2023-05-31gprofng: Fix -Wsign-compare warningVladimir Mezentsev1-1/+2
gprofng/ChangeLog 2023-05-25 Vladimir Mezentsev <vladimir.mezentsev@oracle.com> PR gprofng/30490 * src/LoadObject.cc: Fix -Wsign-compare warning.
2023-05-31gprofng: 29470 The test suite should be made more flexibleVladimir Mezentsev17-119/+311
I add two new targets (check-extra, check-install) for gprofng testing: `make check` runs sanity testing for gprofng and takes ~30 secunds. `make check-extra` runs all gprofng tests and takes ~20 minutus. `make check-install` runs all gprofng tests and uses gprofng installation. On aarch64, there are unwind problems in libgp-collector.so. I set ACCT_FILTER to temporarily ignore problematic functions. gprofng/ChangeLog 2023-05-25 Vladimir Mezentsev <vladimir.mezentsev@oracle.com> PR gprofng/29470 * Makefile.am: Add check-extra, check-install. * Makefile.in: Rebuild * testsuite/config/default.exp: Set the GPROFNG variable. * testsuite/gprofng.display/display.exp: Updated the test list. * testsuite/gprofng.display/jsynprog/Intface.java: Correct copyright. * testsuite/gprofng.display/jsynprog/Launcher.java: Likewise. * testsuite/gprofng.display/jsynprog/Makefile: Likewise. * testsuite/gprofng.display/jsynprog/Routine.java: Likewise. * testsuite/gprofng.display/jsynprog/Sub_Routine.java: Likewise. * testsuite/gprofng.display/jsynprog/cloop.cc: Likewise. * testsuite/gprofng.display/jsynprog/jsynprog.h: Likewise. * testsuite/gprofng.display/jsynprog/jsynprog.java: Correct copyright. Add the -j option to run the selected functions. * testsuite/gprofng.display/synprog/check_results.pl: Remove unused environment variable. * testsuite/gprofng.display/synprog/synprog.c: Updated DEFAULT_COMMAND. * testsuite/lib/Makefile.skel: Apply $(ACCT_FILTER). * testsuite/lib/acct.pm: Ignore errors when $(ACCT_FILTER) is set. * testsuite/lib/display-lib.exp: Add TARGET_FLAGS in make_args.
2023-05-31Improve MI -dprintf-insert documentationTom Tromey2-7/+12
I found the documentation for -dprintf-insert a bit unclear. It didn't mention the possibility of multiple arguments, and I also noticed that it implied that the format parameter is optional, which it is not. While looking into this I also noticed a few comments in the implementation that could also be improved. Then, I noticed a repeated call to strlen in a loop condition, so I fixed this up as well. Reviewed-By: Eli Zaretskii <eliz@gnu.org>
2023-05-31Pass correct name to @value in gdb.texinfoTom Tromey1-2/+2
I noticed a couple instance of this warning when rebuilding the gdb info files: warning: undefined flag: GDB The problem is that the wrong argument was passed to @value. This patch fixes the problem.
2023-05-31[gdb/testsuite] Fix gdb.tui/wrap-line.exp with --disable-tuiTom de Vries1-2/+4
When running the test-case gdb.tui/wrap-line.exp with a build configured with --disable-tui, we run into: ... (gdb) PASS: gdb.tui/wrap-line.exp: width-hard-coded: set width 50 tui new-layout command-layout cmd 1^M Undefined command: "tui". Try "help".^M (gdb) ERROR: Undefined command "tui new-layout command-layout cmd 1". ... Fix this by guarding the command with allow_tui_tests. Tested on x86_64-linux.
2023-05-31[gdb/testsuite] Fix gdb.tui/pr30056.exp for native-extended-gdbserverTom de Vries1-0/+31
When running test-case gdb.tui/pr30056.exp with target board native-extended-gdbserver, I run into: ... Quit^[[K^M^[[B(gdb) PASS: gdb.tui/pr30056.exp: Control-C Remote debugging from host ::1, port 38810^M ^M(failed reverse-i-search)`xyz': ^M(gdb) target extended-remote \ localhost:2346^[[7GWARNING: Timed out waiting for EOF in server after \ monitor exit ... This is due to the fact that ^C doesn't abort the reverse-i-search. This appears to be due to a readline problem. A PR is open about this: PR cli/30498. Add a KFAIL for the PR, and ensure that the isearch is aborted by using ^G, such that we have a responsive prompt to handle the "monitor exit" command that native-extended-gdbserver issues. Tested on x86_64-linux.
2023-05-31pe/coff - add support for base64 encoded long section namesTristan Gingold3-31/+152
PR 30444 * coffcode.h (coff_write_object_contents): Handle base64 encoding on PE. Also check for too large string table. * coffgen.c (extract_long_section_name): New function extracted from ... (make_a_section_from_file): ... here. Add support for base64 long section names. (decode_base64): New function.
2023-05-31Fix printf formating issues in elfxx-loongarch64.cNick Clifton1-5/+5
2023-05-31python, btrace: Fix some small formatting issues.Felix Willgerodt2-5/+6
Reviewed-By: Tom Tromey <tom@tromey.com>
2023-05-31[gdb/tui] Fix fingerprint for cmd-only layoutTom de Vries3-3/+13
I added a cmd-only layout: ... (gdb) tui new-layout cmd cmd 1 ... and set it: ... (gdb) layout cmd ... which gave me the expect result: only the cmd window in the screen. However, after going back to layout src: ... (gdb) layout src ... I got a source window with only one line in it, and the cmd window taking most of the screen. I traced this back to tui_set_layout, where for both the old and the new layout the fingerprint of the cmd window in the layout is taken. If the fingerprint is the same, an effort will be done to preserve the command window size. The fingerprint is "VC" for both the old (cmd) and new (src) layouts, which explains the behaviour. I think this is essentially a bug in the finger print calculation, and it should be "C" for the cmd layout. Fix this by not adding a V or H in the fingerprint if the list size is one. Tested on x86_64-linux. Reviewed-By: Tom Tromey <tom@tromey.com>
2023-05-31Automatic date update in version.inGDB Administrator1-1/+1
2023-05-30gdb: add support for %V to printf commandAndrew Burgess7-11/+158
This commit adds a new format for the printf and dprintf commands: '%V'. This new format takes any GDB expression and formats it as a string, just as GDB would for a 'print' command, e.g.: (gdb) print a1 $a = {2, 4, 6, 8, 10, 12, 14, 16, 18, 20} (gdb) printf "%V\n", a1 {2, 4, 6, 8, 10, 12, 14, 16, 18, 20} (gdb) It is also possible to pass the same options to %V as you might pass to the print command, e.g.: (gdb) print -elements 3 -- a1 $4 = {2, 4, 6...} (gdb) printf "%V[-elements 3]\n", a1 {2, 4, 6...} (gdb) This new feature would effectively replace an existing feature of GDB, the $_as_string builtin convenience function. However, the $_as_string function has a few problems which this new feature solves: 1. $_as_string doesn't currently work when the inferior is not running, e.g: (gdb) printf "%s", $_as_string(a1) You can't do that without a process to debug. (gdb) The reason for this is that $_as_string returns a value object with string type. When we try to print this we call value_as_address, which ends up trying to push the string into the inferior's address space. Clearly we could solve this problem, the string data exists in GDB, so there's no reason why we have to push it into the inferior, but this is an existing problem that would need solving. 2. $_as_string suffers from the fact that C degrades arrays to pointers, e.g.: (gdb) printf "%s\n", $_as_string(a1) 0x404260 <a1> (gdb) The implementation of $_as_string is passed a gdb.Value object that is a pointer, it doesn't understand that it's actually an array. Solving this would be harder than issue #1 I think. The whole array to pointer transformation is part of our expression evaluation. And in most cases this is exactly what we want. It's not clear to me how we'd (easily) tell GDB that we didn't want this reduction in _some_ cases. But I'm sure this is solvable if we really wanted to. 3. $_as_string is a gdb.Function sub-class, and as such is passed gdb.Value objects. There's no super convenient way to pass formatting options to $_as_string. By this I mean that the new %V feature supports print formatting options. Ideally, we might want to add this feature to $_as_string, we might imagine it working something like: (gdb) printf "%s\n", $_as_string(a1, elements = 3, array_indexes = True) where the first item is the value to print, while the remaining options are the print formatting options. However, this relies on Python calling syntax, which isn't something that convenience functions handle. We could possibly rely on strictly positional arguments, like: (gdb) printf "%s\n", $_as_string(a1, 3, 1) But that's clearly terrible as there's far more print formatting options, and if you needed to set the 9th option you'd need to fill in all the previous options. And right now, the only way to pass these options to a gdb.Function is to have GDB first convert them all into gdb.Value objects, which is really overkill for what we want. The new %V format solves all these problems: the string is computed and printed entirely on the GDB side, we are able to print arrays as actual arrays rather than pointers, and we can pass named format arguments. Finally, the $_as_string is sold in the manual as allowing users to print the string representation of flag enums, so given: enum flags { FLAG_A = (1 << 0), FLAG_B = (1 << 1), FLAG_C = (1 << 1) }; enum flags ff = FLAG_B; We can: (gdb) printf "%s\n", $_as_string(ff) FLAG_B This works just fine with %V too: (gdb) printf "%V\n", ff FLAG_B So all functionality of $_as_string is replaced by %V. I'm not proposing to remove $_as_string, there might be users currently depending on it, but I am proposing that we don't push $_as_string in the documentation. As %V is a feature of printf, GDB's dprintf breakpoints naturally gain access to this feature too. dprintf breakpoints can be operated in three different styles 'gdb' (use GDB's printf), 'call' (call a function in the inferior), or 'agent' (perform the dprintf on the remote). The use of '%V' will work just fine when dprintf-style is 'gdb'. When dprintf-style is 'call' the format string and arguments are passed to an inferior function (printf by default). In this case GDB doesn't prevent use of '%V', but the documentation makes it clear that support for '%V' will depend on the inferior function being called. I chose this approach because the current implementation doesn't place any restrictions on the format string when operating in 'call' style. That is, the user might already be calling a function that supports custom print format specifiers (maybe including '%V') so, I claim, it would be wrong to block use of '%V' in this case. The documentation does make it clear that users shouldn't expect this to "just work" though. When dprintf-style is 'agent' then GDB does no support the use of '%V' (right now). This is handled at the point when GDB tries to process the format string and send the dprintf command to the remote, here's an example: Reading symbols from /tmp/hello.x... (gdb) dprintf call_me, "%V", a1 Dprintf 1 at 0x401152: file /tmp/hello.c, line 8. (gdb) set sysroot / (gdb) target remote | gdbserver --once - /tmp/hello.x Remote debugging using | gdbserver --once - /tmp/hello.x stdin/stdout redirected Process /tmp/hello.x created; pid = 3088822 Remote debugging using stdio Reading symbols from /lib64/ld-linux-x86-64.so.2... (No debugging symbols found in /lib64/ld-linux-x86-64.so.2) 0x00007ffff7fd3110 in _start () from /lib64/ld-linux-x86-64.so.2 (gdb) set dprintf-style agent (gdb) c Continuing. Unrecognized format specifier 'V' in printf Command aborted. (gdb) This is exactly how GDB would handle any other invalid format specifier, for example: Reading symbols from /tmp/hello.x... (gdb) dprintf call_me, "%Q", a1 Dprintf 1 at 0x401152: file /tmp/hello.c, line 8. (gdb) set sysroot / (gdb) target remote | gdbserver --once - /tmp/hello.x Remote debugging using | gdbserver --once - /tmp/hello.x stdin/stdout redirected Process /tmp/hello.x created; pid = 3089193 Remote debugging using stdio Reading symbols from /lib64/ld-linux-x86-64.so.2... (No debugging symbols found in /lib64/ld-linux-x86-64.so.2) 0x00007ffff7fd3110 in _start () from /lib64/ld-linux-x86-64.so.2 (gdb) set dprintf-style agent (gdb) c Continuing. Unrecognized format specifier 'Q' in printf Command aborted. (gdb) The error message isn't the greatest, but improving that can be put off for another day I hope. Reviewed-By: Eli Zaretskii <eliz@gnu.org> Acked-By: Simon Marchi <simon.marchi@efficios.com>
2023-05-30gdb: add interp::on_memory_changed methodSimon Marchi5-38/+52
Same idea as previous patches, but for memory_changed. Change-Id: Ic19f20c24d8a6431d4a89c5625e8ef4898f76e82
2023-05-30gdb: add interp::on_param_changed methodSimon Marchi8-40/+35
Same idea as previous patches, but for command_param_changed. Change-Id: I7c2196343423360da05f016f8ffa871c064092bb
2023-05-30gdb: add interp::on_breakpoint_modified methodSimon Marchi8-43/+58
Same idea as previous patches, but for breakpoint_modified. Change-Id: I4f0a9edea912de431e32451d74224b2022a7c328
2023-05-30gdb: add interp::on_breakpoint_deleted methodSimon Marchi5-22/+31
Same idea as previous patches, but for breakpoint_deleted. Change-Id: I59c231ce963491bb1eee1432ee1090138f09e19c
2023-05-30gdb: add interp::on_breakpoint_created methodSimon Marchi5-22/+33
Same idea as previous patches, but for breakpoint_created. Change-Id: I614113c924edc243590018b8fb3bf69cb62215ef
2023-05-30gdb: add interp::on_tsv_modified methodSimon Marchi7-32/+30
Same idea as previous patches, but for tsv_modified. Change-Id: I55454a2386d5450040b3a353909b26f389a43682
2023-05-30gdb: add interp::on_tsv_deleted methodSimon Marchi7-29/+29
Same idea as previous patches, but for tsv_deleted. Change-Id: I71b0502b493da7b6e293bee02aeca98de83d4b75
2023-05-30gdb: add interp::on_tsv_created methodSimon Marchi7-26/+26
Same idea as previous patches, but for tsv_created. Change-Id: I9c30ecfdbd78ca015d613f43a0c0aef6c7eb32b5
2023-05-30gdb: add interp::on_traceframe_changed methodSimon Marchi7-32/+32
Same idea as previous patches, but for traceframe_changed. Change-Id: Ia473f07d70d57b30aca0094d0e0585d7e0d95637
2023-05-30gdb: add interp::on_about_to_proceed methodSimon Marchi4-11/+19
Same idea as previous patches, but for about_to_proceed. We only need (and want, as far as the mi_interp implementation is concerned) to notify the interpreter that caused the proceed. Change-Id: Id259bca10dbc3d43d46607ff7b95243a9cbe2f89
2023-05-30gdb: add interp::on_solib_unloaded methodSimon Marchi5-28/+39
Same idea as previous patches, but for solib_unloaded. Change-Id: Iad847de93f0b38b5c90679a173d3beeaed7af6c5
2023-05-30gdb: add interp::on_solib_loaded methodSimon Marchi5-21/+35
Same idea as previous patches, but for solib_loaded Change-Id: I85edb0a4b377f4b2c39ffccf31cb75f38bae0f55
2023-05-30gdb: add interp::on_target_resumed methodSimon Marchi5-18/+32
Same idea as previous patches, but for target_resumed. Change-Id: I66fa28d1d41a1f3c4fb0d6a470137d493eac3c8c
2023-05-30gdb: add interp::on_record_changed methodSimon Marchi9-57/+57
Same idea as previous patches, but for record_changed Change-Id: I5eeeacd703af8401c315060514c94e8e6439cc40
2023-05-30gdb: add interp::on_inferior_removed methodSimon Marchi5-19/+31
Same idea as previous patches, but for inferior_removed. Change-Id: I7971840bbbdcfabf77e2ded7584830c9dfdd10d0
2023-05-30gdb: add interp::on_inferior_disappeared methodSimon Marchi5-23/+37
Same idea as previous patches, but for inferior_disappeared. For symmetry with on_inferior_appeared, I named this one on_inferior_disappeared, despite the observer being called inferior_exit. This is called when detaching an inferior, so I think that calling it "disappeared" is a bit less misleading (the observer should probably be renamed later). Change-Id: I372101586bc9454997953c1e540a2a6685f53ef6
2023-05-30gdb: add interp::on_inferior_appeared methodSimon Marchi5-21/+34
Same idea as previous patches, but for inferior_appeared. Change-Id: Ibe4feba34274549a886b1dfb5b3f8d59ae79e1b5
2023-05-30gdb: add interp::on_inferior_added methodSimon Marchi5-39/+35
Same idea as previous patches, but for inferior_added. mi_interp::init avoided using mi_inferior_added, since, as the comment used to say, it would notify all MI interpreters. Now, it's easy to only notify the new interpreter, so it's possible to just call the on_inferior_added method in mi_interp::init. Change-Id: I0eddbd5367217d1c982516982089913019ef309f
2023-05-30gdb: add interp::on_thread_exited methodSimon Marchi5-19/+32
Same idea as previous patches, but for thread_exited. Change-Id: I4be974cbe58cf635453fef503c2d77c82522cbd9
2023-05-30gdb: add interp::on_new_thread methodSimon Marchi5-19/+34
Same idea as previous patches, but for new_thread. Change-Id: Ib70ae3421b736fd69d86c4e7c708bec349aa256c
2023-05-30gdb: add interp::on_user_selected_context_changed methodSimon Marchi12-83/+66
Same as previous patches, but for user_selected_context_changed. Change-Id: I40de15be897671227d4bcf3e747f0fd595f0d5be
2023-05-30gdb: add interp::on_command_error methodSimon Marchi8-23/+12
Same idea as the previous patches, but for command_error. Change-Id: If6098225dd72fad8be13b3023b35bc8bc48efb9d
2023-05-30gdb: add interp::on_sync_execution_done methodSimon Marchi8-28/+12
Same as previous patches, but for sync_execution_done. Except that here, we only want to notify the interpreter that is executing the command, not all interpreters. Change-Id: I729c719447b5c5f29af65dbf6fed9132e2cd308b
2023-05-30gdb: add interp::on_no_history methodSimon Marchi9-55/+26
Same as previous patches, but for no_history. Change-Id: I06930fe7cb4082138c6c5496c5118fe4951c10da
2023-05-30gdb: add interp::on_exited methodSimon Marchi9-34/+26
Same as previous patch, but for exited. Remove the exited observable, since nothing uses it anymore, and we don't have anything coming that will use it. Change-Id: I358cbea0159af56752dfee7510d6a86191e722bb
2023-05-30gdb: add interp::on_signal_exited methodSimon Marchi9-36/+27
Same as previous patch, but for signal_exited. Remove the signal_exited observable, since nothing uses it anymore, and we don't have anything coming that will use it. Change-Id: I0dca1eab76338bf27be755786e3dad3241698b10
2023-05-30gdb: add interp::on_normal_stop methodSimon Marchi9-58/+57
Same idea as the previous patch, but for the normal_stop event. Change-Id: I4fc8ca8a51c63829dea390a2b6ce30b77f9fb863
2023-05-30gdb: add interp::on_signal_received methodSimon Marchi9-33/+59
Instead of having the interpreter code registering observers for the signal_received observable, add a "signal_received" virtual method to struct interp. Add a interps_notify_signal_received function that loops over all UIs and calls the signal_received method on the interpreter. Finally, add a notify_signal_received function that calls interps_notify_signal_received and then notifies the observers. Replace all existing notifications to the signal_received observers with calls to notify_signal_received. Before this patch, the CLI and MI code both register a signal_received observer. These observer go over all UIs, and, for those that have a interpreter of the right kind, print the stop notifiation. After this patch, we have just one "loop over all UIs", inside interps_notify_signal_received. Since the interp::on_signal_received method gets called once for each interpreter, the implementations only need to deal with the current interpreter (the "this" pointer). The motivation for this patch comes from a future patch, that makes the amdgpu code register an observer to print a warning after the CLI's signal stop message. Since the amdgpu and the CLI code both use observers, the order of the two messages is not stable, unless we define the priority using the observer dependency system. However, the approach of using virtual methods on the interpreters seems like a good change anyway, I think it's more straightforward and simple to understand than the current solution that uses observers. We are sure that the amdgpu message gets printed after the CLI message, since observers are notified after interpreters. Keep the signal_received, even if nothing uses if, because we will be using it in the upcoming amdgpu patch implementing the warning described above. Change-Id: I4d8614bb8f6e0717f4bfc2a59abded3702f23ac4
2023-05-30[gdb] Mention --with/without-system-readline for --configurationTom de Vries3-0/+22
Simon reported that the new test-case gdb.tui/pr30056.exp fails with system readline. This is because the test-case requires a fix in readline that's present in our in-repo copy of readline, but most likely not in any system readline yet. Fix this by: - mentioning --with-system-readline or --without-system-readline in the configuration string. - adding a new proc with_system_readline that makes this information available in the testsuite. - using this in test-case gdb.tui/pr30056.exp to declare it unsupported for --with-system-readline. Tested on x86_64-linux. Reported-By: Simon Marchi <simon.marchi@efficios.com> Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-05-30Slight wording improvement for the -Ur documentationNick Clifton1-4/+5
2023-05-30Improve header information displayed with objdump -P for PE binaries.Nick Clifton2-95/+308
* od-pe.c (targ_info): New array. (get_target_specific_info): New function. (decode_machine_number): Retire. Use get_target_specific_info instead. (is_pe_object_magic): Likewise. (dump_pe_file_header): Display more information. Rework layout to be similar to that from 'objdump -p'. Add code to handle larger than normnal AOUT headers.
2023-05-30LoongArch: ld: Add support for linker relaxation.mengqinggang14-56/+273
Add ld relax support and testsuits. ld/ChangeLog: * emultempl/loongarchelf.em: Regenerated. * testsuite/ld-elf/compressed1d.d: Xfail loongarch*-*. * testsuite/ld-elf/pr26936.d: Likewise. * testsuite/ld-loongarch-elf/disas-jirl.d: Regenerated. * testsuite/ld-loongarch-elf/disas-jirl-32.d: Regenerated. * testsuite/ld-loongarch-elf/jmp_op.d: Likewise. * testsuite/ld-loongarch-elf/macro_op.d: Likewise. * testsuite/ld-loongarch-elf/macro_op_32.d: Likewise. * testsuite/ld-loongarch-elf/relax-align.dd: New test. * testsuite/ld-loongarch-elf/relax-align.s: New test. * testsuite/ld-loongarch-elf/relax.exp: New test. * testsuite/ld-loongarch-elf/relax.s: New test. * testsuite/ld-loongarch-elf/uleb128.dd: New test. * testsuite/ld-loongarch-elf/uleb128.s: New test.
2023-05-30LoongArch: gas: Add support for linker relaxation.mengqinggang30-229/+725
Add gas -mrelax and -mno-relax option. Add R_LARCH_RELAX reloc for instrction if it can be relaxed. ADD R_LARCH_ALIGN reloc for align pseudo instruction because relax. Add ADD/SUB reloc pair for debug and exception data to calculate symbol substraction because relax. gas/ChangeLog: * config/tc-loongarch.c: (struct loongarch_cl_insn): New macro_id member. (enum options): New OPTION_RELAX and OPTION_NO_RELAX. (struct option): New mrelax and mno-relax. (md_parse_option): Likewise. (get_internal_label): (loongarch_args_parser_can_match_arg_helper): Generate relax reloc. (move_insn): Set fx_frag and fx_where if exist. (append_fixp_and_insn): Call frag_wane and frag_new for linker relax relocs. (loongarch_assemble_INSNs): New loongarch_cl_insn pointer parameter. (md_assemble): Fix function call. (fix_reloc_insn): Likewise. (md_apply_fix): Generate ADD/SUB reloc pair for debug and exception data. (loongarch_fix_adjustable): Delete. (md_convert_frag): Generate new fix. (loongarch_pre_output_hook): New function. (loongarch_make_nops): Likewise. (loongarch_frag_align_code): Likewise. (loongarch_insert_uleb128_fixes): Likewise. (loongarch_md_finish): Likewise. * config/tc-loongarch.h (md_allow_local_subtract): New macro define. (loongarch_frag_align_code): New declare. (md_do_align): Likewise. (loongarch_fix_adjustable): Delete. (tc_fix_adjustable): New macro define. (TC_FORCE_RELOCATION_SUB_SAME): Likewise. (TC_LINKRELAX_FIXUP): Likewise. (TC_FORCE_RELOCATION_LOCAL): Likewise. (DWARF2_USE_FIXED_ADVANCE_PC): Likewise. (MD_APPLY_SYM_VALUE): Likewise. (tc_symbol_new_hook): New extern. (NOP_OPCODE): Delete. (loongarch_pre_output_hook): New macro define. (md_pre_output_hook): Likewise. (md_finish): Likewise. (loongarch_md_finish): New extern. * testsuite/gas/all/align.d: Mark as unsupported on LoongArch. * testsuite/gas/all/gas.exp: Xfail loongarch*-*. * testsuite/gas/all/relax.d: Likewise. * testsuite/gas/elf/dwarf-5-irp.d: Likewise. * testsuite/gas/elf/dwarf-5-loc0.d: Likewise. * testsuite/gas/elf/dwarf-5-macro-include.d: Likewise. * testsuite/gas/elf/dwarf-5-macro.d: Likewise. * testsuite/gas/elf/dwarf2-11.d: Likewise. * testsuite/gas/elf/dwarf2-15.d: Likewise. * testsuite/gas/elf/dwarf2-16.d: Likewise. * testsuite/gas/elf/dwarf2-17.d: Likewise. * testsuite/gas/elf/dwarf2-18.d: Likewise. * testsuite/gas/elf/dwarf2-19.d: Likewise. * testsuite/gas/elf/dwarf2-5.d: Likewise. * testsuite/gas/elf/ehopt0.d: Likewise. * testsuite/gas/elf/elf.exp: Likewise. * testsuite/gas/elf/section11.d: Likewise. * testsuite/gas/lns/lns.exp: Likewise. * testsuite/gas/loongarch/jmp_op.d: Regenerated. * testsuite/gas/loongarch/li.d: Likewise. * testsuite/gas/loongarch/macro_op.d: Likewise. * testsuite/gas/loongarch/macro_op_32.d: Likewise. * testsuite/gas/loongarch/macro_op_large_abs.d: Likewise. * testsuite/gas/loongarch/macro_op_large_pc.d: Likewise. * testsuite/gas/loongarch/relax_align.d: New test. * testsuite/gas/loongarch/relax_align.s: New test. * testsuite/gas/loongarch/uleb128.d: New test. * testsuite/gas/loongarch/uleb128.s: New test.