• R/O
  • HTTP
  • SSH
  • HTTPS

Liste der Commits

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


users/keiths/inline-func-bp-for-pedro
RSS
Rev. Zeit Autor
a62f06e users/keiths/inline-func-bp-for-pedro 2017-11-29 06:23:10 Keith Seitz

More minimal patch

Same thing but using the exception, leaving bpstat_stop_status call
where it is.

This and the previous commit are intended to be exported to an stgit branch,
where one can easily switch between the two approaches by push/pop'ing
patches. Diffing against origin/master will therefore always give a complete
patch sans busywork.

83b9557 2017-11-29 05:39:19 Keith Seitz

Report stop locations in inlined functions

This is a patch for a very related inline function problem. Using the
test case from breakpoints/17534,

3 static inline void NVIC_EnableIRQ(int IRQn)
4 {
5 volatile int y;
6 y = IRQn;
7 }
8
9 __attribute__( ( always_inline ) ) static inline void __WFI(void)
10 {
11 __asm volatile ("nop");
12 }
13
14 int main(void) {
15
16 x= 42;
17
18 if (x)
19 NVIC_EnableIRQ(16);
20 else
21 NVIC_EnableIRQ(18);
(gdb) b NVIC_EnableIRQ
Breakpoint 1 at 0x4003e4: NVIC_EnableIRQ. (2 locations)
(gdb) r
Starting program: 17534

Breakpoint 1, main () at 17534.c:19
19 NVIC_EnableIRQ(16);

This happens because skip_inline_frames automatically skips every inlined
frame. Based on a suggestion by Jan, this patch introduces a new function,
breakpoint_for_stop, which attempts to ascertain which breakpoint, if any,
caused a particular stop in the inferior. That breakpoint is then passed
to skip_inline_frames so that it can decide if a particular inlined frame
should be skipped.

I've had to separate the bpstat chain building from bpstat_stop_status --
py-finish-breakpoint.exp did not like me calling bpstat_stop_status multiple
times. So I've added the ability to allocate the chain separately and
optionally pass it to bpstat_stop_status, which remains otherwise unchanged.

With this patch, GDB now correctly reports that the inferior has stopped
inside the inlined function:

(gdb) r
Starting program: 17534

Breakpoint 1, NVIC_EnableIRQ (IRQn=16) at 17534.c:6
6 y = IRQn;


gdb/ChangeLog:

* breakpoint.c (bpstat_explains_signal): Add output parameter for
breakpoint and save the breakpoint if one is found to explain
the signal.
All callers updated.
(build_bpstat_chain): New function, moved from bpstat_stop_status.
(breakpoint_for_stop): New function.
(bpstat_stop_status): Add new optional parameter for the bpstat chain.
If this new parameter is NULL, call build_bpstat_chain.
All callers updated.
* breakpoint.h (breakpoint_for_stop): Declare.
(bpstat_explains_signal): Update declaration.
* infrun.c (handle_signal_stop): Before calling skip_inline_frames,
use breakpoint_for_stop to find the breakpoint that caused us
to stop.
Save the bpstat chain for later invocation of bpstat_stop_status.
* inline-frame.c: Include linespec.h.
(skip_inline_frames): Add struct breakpoint parameter.
Re-parse the location of the breakpoint causing the stop, if any,
and only skip frames that did not cause the stop.
* inline-frame.h (skip_inline_frames): Update declaration.

gdb/testsuite/ChangeLog:

* gdb.opt/inline-break.c (inline_func1, not_inline_func1)
(inline_func2, not_inline_func2, inline_func3, not_inline_func3):
New functions.
(main): Call not_inline_func3.
* gdb.opt/inline-break.exp: Start inferior and set breakpoints at
inline_func1, inline_func2, and inline_func3. Test that when each
breakpoint is hit, GDB properly reports both the stop location
and the backtrace.

b0029dc 2017-11-29 03:00:29 Nick Clifton

Prevent a memory exhaustion problem when trying to read in strings from a COFF binary with a corrupt string table size.

PR 22507
* coffgen.c (_bfd_coff_read_string_table): Check for an excessive
size of the external string table.

ff174d3 2017-11-29 02:00:44 H.J. Lu

gold: Add a newline at end of pr22266_a.c

This patch fixes the build with GCC 4.2:

gold/testsuite/pr22266_a.c:13:2: error: no newline at end of file

* testsuite/pr22266_a.c: Add a newline at end of file.

82ed968 2017-11-29 01:18:46 H.J. Lu

Properly handle note sections and segments

When dumping notes, get note alignment from either note section or note
segment. To support notes generated by assemblers with

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

we treate alignment as 4 bytes if it is less than 4. Otherwise, we skip
notes if alignment isn't 4 nor 8 bytes.

We should call load_separate_debug_file only if e_shstrndx != SHN_UNDEF.

PR binutils/22490
* readelf.c (process_notes_at): Add an argument for note
alignment. If note alignment is less than 4, use 4 byte
alignment. Otherwise, skip notes if alignment isn't 4 nor
8 bytes.
(process_corefile_note_segments): Pass segment alignment to
process_notes_at.
(process_note_sections): Pass section alignment to
process_notes_at.
(process_object): Call load_separate_debug_file only if
e_shstrndx != SHN_UNDEF.

b23dc97 users/ARM/embedded-binutils-master-2017q4 users/ARM/embedded-gdb-master-2017q4 2017-11-28 22:20:31 Nick Clifton

Fix a memory access violation when attempting to parse a corrupt COFF binary with a relocation that points beyond the end of the section to be relocated.

PR 22506
* reloc.c (reloc_offset_in_range): Rename to
bfd_reloc_offset_in_range and export.
(bfd_perform_relocation): Rename function invocation.
(bfd_install_relocation): Likewise.
(bfd_final_link_relocate): Likewise.
* bfd-in2.h: Regenerate.
* coff-arm.c (coff_arm_reloc): Use bfd_reloc_offset_in_range.
* coff-i386.c (coff_i386_reloc): Likewise.
* coff-i860.c (coff_i860_reloc): Likewise.
* coff-m68k.c (mk68kcoff_common_addend_special_fn): Likewise.
* coff-m88k.c (m88k_special_reloc): Likewise.
* coff-mips.c (mips_reflo_reloc): Likewise.
* coff-x86_64.c (coff_amd64_reloc): Likewise.

6c6bc89 2017-11-28 21:55:34 H.J. Lu

ELF: Don't set non_ir_ref_regular in check_relocs

Since elf_link_add_object_symbols sets non_ir_ref_regular now, there is
no need to set non_ir_ref_regular in check_relocs.

Tested on i686 and x86-64.

* elf-m10300.c (mn10300_elf_check_relocs): Don't set
non_ir_ref_regular.
* elf32-arm.c (elf32_arm_check_relocs): Likewise.
* elf32-bfin.c (bfin_check_relocs): Likewise.
* elf32-cr16.c (cr16_elf_check_relocs): Likewise.
* elf32-cris.c (cris_elf_check_relocs): Likewise.
* elf32-d10v.c (elf32_d10v_check_relocs): Likewise.
* elf32-dlx.c (elf32_dlx_check_relocs): Likewise.
* elf32-fr30.c (fr30_elf_check_relocs): Likewise.
* elf32-frv.c (elf32_frv_check_relocs): Likewise.
* elf32-hppa.c (elf32_hppa_check_relocs): Likewise.
* elf32-i370.c (i370_elf_check_relocs): Likewise.
* elf32-i386.c (elf_i386_check_relocs): Likewise.
* elf32-iq2000.c (iq2000_elf_check_relocs): Likewise.
* elf32-lm32.c (lm32_elf_check_relocs): Likewise.
* elf32-m32c.c (m32c_elf_check_relocs): Likewise.
* elf32-m32r.c (m32r_elf_check_relocs): Likewise.
* elf32-m68hc1x.c (elf32_m68hc11_check_relocs): Likewise.
* elf32-m68k.c (elf_m68k_check_relocs): Likewise.
* elf32-mcore.c (mcore_elf_check_relocs): Likewise.
* elf32-metag.c (elf_metag_check_relocs): Likewise.
* elf32-microblaze.c (microblaze_elf_check_relocs): Likewise.
* elf32-moxie.c (moxie_elf_check_relocs): Likewise.
* elf32-msp430.c (elf32_msp430_check_relocs): Likewise.
* elf32-mt.c (mt_elf_check_relocs): Likewise.
* elf32-nios2.c (nios2_elf32_check_relocs): Likewise.
* elf32-or1k.c (or1k_elf_check_relocs): Likewise.
* elf32-ppc.c (ppc_elf_check_relocs): Likewise.
* elf32-rl78.c (rl78_elf_check_relocs): Likewise.
* elf32-s390.c (elf_s390_check_relocs): Likewise.
* elf32-score.c (s3_bfd_score_elf_check_relocs): Likewise.
* elf32-score7.c (s7_bfd_score_elf_check_relocs): Likewise.
* elf32-sh.c (sh_elf_check_relocs): Likewise.
* elf32-tic6x.c (elf32_tic6x_check_relocs): Likewise.
* elf32-tilepro.c (tilepro_elf_check_relocs): Likewise.
* elf32-v850.c (v850_elf_check_relocs): Likewise.
* elf32-vax.c (elf_vax_check_relocs): Likewise.
* elf32-xstormy16.c (xstormy16_elf_check_relocs): Likewise.
* elf32-xtensa.c (elf_xtensa_check_relocs): Likewise.
* elf64-aarch64.c (elf64_aarch64_check_relocs): Likewise.
* elf64-alpha.c (elf64_alpha_check_relocs): Likewise.
* elf64-hppa.c (elf64_hppa_check_relocs): Likewise.
* elf64-ia64-vms.c (elf64_ia64_check_relocs): Likewise.
* elf64-mmix.c (mmix_elf_check_relocs): Likewise.
* elf64-ppc.c (ppc64_elf_check_relocs): Likewise.
* elf64-s390.c (elf_s390_check_relocs): Likewise.
* elf64-sh64.c (sh_elf64_check_relocs): Likewise.
* elf64-x86-64.c (elf_x86_64_check_relocs): Likewise.
* elfnn-aarch64.c (elfNN_aarch64_check_relocs): Likewise.
* elfnn-ia64.c (elfNN_ia64_check_relocs): Likewise.
* elfnn-riscv.c (riscv_elf_check_relocs): Likewise.
* elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Likewise.
* elfxx-tilegx.c (tilegx_elf_check_relocs): Likewise.

165f707 2017-11-28 21:27:00 Alan Modra

PR22471, undefined reference to linker-defined symbols

This patch processes linker script assignment statements before ld
opens DT_NEEDED libraries, in order to define symbols like __bss_start
that might also be defined by a library, falsely triggering an error
about "DSO missing from command line".

The initial value won't be correct when assigning a symbol from dot,
and I make no attempt to handle all expressions. For example, an
assignment like "_start_foo = ADDR (.foo)" isn't valid until sections
are laid out, so won't define _start_foo early. What's here should be
enough for most common scripts, and hopefully won't perturb fragile
scripts.

bfd/
PR 22471
* elflink.c (_bfd_elf_merge_symbol): Allow weak symbols to override
early passes over linker script symbols.
* linker.c (_bfd_generic_link_add_one_symbol): Allow symbols to
override early passes over linker script symbols. Clear ldscript_def
on symbol definitions.
ld/
PR 22471
* ldexp.c (struct definedness_hash_entry): Delete "by_script". Make
"iteration" an 8-bit field, and update mask in all uses.
(definedness_newfunc): Don't init "by_script".
(update_definedness): Test ldscript_def rather than by_script.
(is_sym_value): Likewise.
(fold_name <DEFINED>): Return a result for first phase. Test
ldscript_def.
(fold_name <NAME>): Return a result for first phase.
* ldlang.c (open_input_bfds): Process all assignments, not just
defsym.
(lang_process): Increment lang_statement_iteration before
open_input_bfds.
* testsuite/ld-mips-elf/tlsdyn-o32-1.d: Adjust for larger .dynsym.
* testsuite/ld-mips-elf/tlsdyn-o32-1.got: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-2.d: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-2.got: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-3.d: Likewise.
* testsuite/ld-mips-elf/tlsdyn-o32-3.got: Likewise.

cd5b2ba 2017-11-28 21:26:59 Alan Modra

Copying symbol type in ld script assignments

There is a call to update_definedness between code that evaluates an
assignment expression value and code that transfers symbol
attributes. When script assignment expressions contain DEFINED, that
can mean the wrong symbol type is copied. This patch tracks symbols
read during expression evaluation, rather than examining the
expression and re-evaluating conditionals. Not only does this
simplify the code, it also means ld can now copy symbol types in more
complex expressions.

An unfortunate side effect of copying symbol type for more complex
expressions affects mmix, which uses
PROVIDE (Main = DEFINED (Main) ? Main : (DEFINED (_start) ? _start : _start.));
in a default script. So now _start or _start. symbol type may be
copied, losing the function type specially set up for Main. This can
be avoided by making bfd_copy_link_hash_symbol_type do nothing for
mmix.

bfd/
* elf64-mmix.c (bfd_elf64_bfd_copy_link_hash_symbol_type): Define.
ld/
* ldexp.h (struct ldexp_control): Add "assign_src".
* ldexp.c (fold_trinary): Save and restore assign_src around
condition evaluation.
(fold_name <NAME>): Set expld.assign_src.
(try_copy_symbol_type): Delete.
(exp_fold_tree_1): Set symbol type using expld.assign_src.

a83ef4d 2017-11-28 20:48:44 H.J. Lu

ld: Set non_ir_ref_regular on symbols referenced in regular objects

If linker plugin is enabled, set non_ir_ref_regular on symbols referenced
in regular objects so that linker plugin will get the correct symbol
resolution.

bfd/

PR ld/22502
* elflink.c (_bfd_elf_merge_symbol): Also skip definition from
an IR object.
(elf_link_add_object_symbols): If linker plugin is enabled, set
non_ir_ref_regular on symbols referenced in regular objects so
that linker plugin will get the correct symbol resolution.

ld/

PR ld/22502
* testsuite/ld-plugin/lto.exp: Run PR ld/22502 test.
* testsuite/ld-plugin/pr22502a.c: New file.
* testsuite/ld-plugin/pr22502b.c: Likewise.

f0531ed 2017-11-28 12:20:53 Jim Wilson

Compress loads/stores with implicit 0 offset.

gas/
* config/tc-riscv.c (riscv_handle_implicit_zero_offset): New.
(riscv_ip): Cases 'k', 'l', 'm', 'n', 'M', 'N', add call to
riscv_handle_implicit_zero_offset. At label load_store, replace
existing code with call to riscv_handle_implicit_zero_offset.
* testsuite/gas/riscv/c-ld.d, testsuite/gas/riscv/c-ld.s: New.
* testsuite/gas/riscv/c-lw.d, testsuite/gas/riscv/c-lw.s: New.
* testsuite/gas/riscv/riscv.exp: Run new tests.

033bfb7 2017-11-28 10:32:55 Cary Coutant

Fix symbol values and relocation addends for relocatable links.

The fix for PR 19291 broke some other cases where -r is used with scripts,
as reported in PR 22266. The original fix for PR 22266 ended up breaking
many cases for REL targets, where the addends are stored in the section data,
and are not being adjusted properly.

The problem was basically that in a relocatable output file (ET_REL),
symbol values are supposed to be relative to the start address of their
section. Usually in a relocatable file, all sections start at 0, so the
failure to get this right is often irrelevant, but with a linker script,
we occasionally see an output section whose starting address is not 0,
and gold would occasionally write a symbol with its relocated value instead
of its section-relative value.

This patch reverts the recent fix for PR 22266 as well as my original fix
for PR 19291. The original fix moved the symbol value adjustment to
write_local_symbols, but neglected to undo a few places where the adjustment
was also being applied, resulting in an occasional double adjustment. The
more recent fix removed those other adjustments, but then failed to
re-account for the adjustment when rewriting the relocations on REL targets.

With the old attempts reverted, we now apply the symbol value adjustment to
the one case that had been missed (non-section symbols in merge sections).
But now we also need to account for the adjustment when rewriting the addends
for RELA relocations.

gold/
PR gold/19291
PR gold/22266
* object.cc (Sized_relobj_file::compute_final_local_value_internal):
Revert changes from 2017-11-08 patch. Adjust symbol value in
relocatable links for non-section symbols.
(Sized_relobj_file::compute_final_local_value): Revert changes from
2017-11-08 patch.
(Sized_relobj_file::do_finalize_local_symbols): Likewise.
(Sized_relobj_file::write_local_symbols): Revert changes from
2015-11-25 patch.
* object.h (Sized_relobj_file::compute_final_local_value_internal):
Revert changes from 2017-11-08 patch.
* powerpc.cc (Target_powerpc::relocate_relocs): Adjust addend for
relocatable links.
* target-reloc.h (relocate_relocs): Adjust addend for relocatable links.
* testsuite/pr22266_a.c (hello): New function.
* testsuite/pr22266_main.c (main): Add test for merge sections.
* testsuite/pr22266_script.t: Add rule for .rodata.

57c1b68 2017-11-28 09:00:24 GDB Administrator

Automatic date update in version.in

18ca734 2017-11-28 08:53:27 Tom Tromey

Remove REMOTE_OBS

This removes REMOTE_OBS from the Makefile. It is no longer needed, as
remote support is always built into gdb. The relevant sources are now
added to COMMON_SFILES, where they are treated like other ordinary
sources.

ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>

* Makefile.in (REMOTE_OBS): Remove.
(SFILES): Remove remote sources.
(COMMON_SFILES): Add remote sources.
(ALLDEPFILES): Remove dcache.c.

66599a7 2017-11-28 08:53:27 Tom Tromey

Move target object files to target subdirectory

Move the object files corresponding to target/*.c to the target
subdirectory in the build tree.

ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>

* Makefile.in (SUBDIR_TARGET_SRCS, SUBDIR_TARGET_OBS): New
variables.
(SFILES): Use SUBDIR_TARGET_SRCS.
(COMMON_OBS): Use SUBDIR_TARGET_OBS. Remove waitstatus.o.
(CONFIG_SRC_SUBDIR): Add target.
(%.o): Remove target rule.

4f04fba 2017-11-28 08:53:26 Tom Tromey

Add missing files to COMMON_SFILES

While working on the previous patch, I found a few .o files whose
corresponding .c file was not mentioned in Makefile.in. This patch
fixes the problem. I pulled this out separately to make it simpler to
review.

ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>

* Makefile.in (COMMON_OBS): Remove filename-seen-cache.o,
registry.o, thread-fsm.o, debug.o.
(COMMON_SFILES): Add filename-seen-cache.c, registry.c,
thread-fsm.c, debug.c.

b5adff3 2017-11-28 08:53:26 Tom Tromey

Simplify COMMON_OBS by using list of sources

This introduces a new COMMON_SFILES variable, and then defines some of
COMMON_OBS in terms of this new variable. This simpifies adding a new
ordinary source file.

ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>

* Makefile.in (COMMON_SFILES): New.
(SFILES): Move some entries to COMMON_SFILES.
(COMMON_OBS): Use COMMON_SFILES.

afa0a41 2017-11-28 08:53:25 Tom Tromey

Define YYOBJ in terms of YYFILES

Change YYOBJ to be defined in terms of YYFILES.

ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>

* Makefile.in (YYFILES): Update comment.
(YYOBJ): Redefine.

8fd8d00 2017-11-28 08:53:25 Tom Tromey

Move python object files to python subdirectory

Move the object files corresponding to python/*.c to the python
subdirectory in the build tree.

Because special CFLAGS are passed just to Python compilations, this
patch also required the addition of a pattern rule to update
INTERNAL_CFLAGS for here.

ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>

* Makefile.in (SUBDIR_PYTHON_OBS): Redefine.
(CONFIG_SRC_SUBDIR): Add python.
(%.o): Remove python rule.
(python/%.o): New rule.
* configure: Rebuild.
* configure.ac (CONFIG_OBS): Refer to python/python.o

bd810ff 2017-11-28 08:53:24 Tom Tromey

Move guile object files to guile subdirectory

Move the object files corresponding to guile/*.c to the guile
subdirectory in the build tree.

ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>

* configure: Rebuild.
* configure.ac (CONFIG_OBS): Refer to guile/guile.o.
* Makefile.in (SUBDIR_GUILE_OBS): Redefine.
(CONFIG_SRC_SUBDIR): Add guile.
(%.o): Remove guile rule.

75787ac 2017-11-28 08:53:24 Tom Tromey

Move unittests object files to unittests subdirectory

Move the object files corresponding to unittests/*.c to the unittests
subdirectory in the build tree.

ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>

* Makefile.in (SUBDIR_UNITTESTS_OBS): Redefine.
(%.o): Remove unittests rule.
(CONFIG_SRC_SUBDIR): Add unittests.

5c8a943 2017-11-28 08:53:23 Tom Tromey

Move tui object files to tui subdirectory

Move the object files corresponding to tui/*.c to the tui subdirectory
in the build tree.

ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>

* Makefile.in (SUBDIR_TUI_OBS): Redefine.
(CONFIG_SRC_SUBDIR): Add tui.
(%.o): Remove tui rule.

a26aa30 2017-11-28 08:53:23 Tom Tromey

Move compile object files to compile subdirectory

Move the object files corresponding to compile/*.c to the compile
subdirectory in the build tree.

ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>

* Makefile.in (SUBDIR_GCC_COMPILE_OBS): Redefine.
(%.o): Remove compile rule.
(CONFIG_SRC_SUBDIR): Add compile.

6f3cdf9 2017-11-28 08:53:22 Tom Tromey

Move mi objects to mi subdirectory

Move object files corresponding to mi/*.c to a subdirectory in the
build tree.

ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>

* Makefile.in (SUBDIR_MI_OBS): Redefine.
(%.o): Remove mi rule.
(CONFIG_SRC_SUBDIR): Add mi.
(COMMON_OBS): Use mi/mi-common.o

f06afa5 2017-11-28 08:53:22 Tom Tromey

Move cli object files to cli subdirectory

Following the "arch" move, this moves the object files corresponding
to the cli/*.c source files to the "cli" build directory.

ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>

* Makefile.in (SUBDIR_CLI_OBS): Redefine.
(%.o): Remove cli rule.
(CONFIG_SRC_SUBDIR): Add cli.

b22c88c 2017-11-28 08:53:21 Tom Tromey

A simpler way to make the "arch" build directory

This implements a simpler way to make the "arch" build directory --
namely, now it is done as an order-only dependency in the Makefile,
rather than being created when config.status is run. This simpler
because it means that the build directories can be changed without
re-running autoconf.

ChangeLog
2017-11-27 Tom Tromey <tom@tromey.com>

* configure.ac (CONFIG_SRC_SUBDIR): Don't subst.
* configure: Rebuild.
* Makefile.in (CONFIG_SRC_SUBDIR): Redefine.
(CONFIG_DEP_SUBDIR): New variable.
(%.o): Add order-only dependency.
($(CONFIG_DEP_SUBDIR)): New target.

407e114 2017-11-28 08:16:22 Max Filippov

gas: xtensa: speed up find_trampoline_seg

find_trampoline_seg takes noticeable time when assembling source with
many sections. Cache the result of the most recent search and check it
first. No functional changes.

gas/
2017-11-27 Max Filippov <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (find_trampoline_seg): Add static variable
that caches the result of the most recent search.

148d638 2017-11-28 08:15:46 Max Filippov

gas: xtensa: implement trampoline coalescing

There is a recurring pattern in assembly files generated by a compiler
where a lot of jumps in a function are going to the same place. When
these jumps are relaxed with trampolines the assembler generates a
separate jump thread from each source.
Create an index of trampoline jump targets for each segment and see if a
jump being relaxed goes to a location from that index, in which case
replace its target with a location of existing trampoline jump that
results in the shortest path to the original target.

gas/
2017-11-27 Max Filippov <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (trampoline_chain_entry, trampoline_chain)
(trampoline_chain_index): New structures.
(trampoline_index): Add chain_index field.
(xg_order_trampoline_chain_entry, xg_sort_trampoline_chain)
(xg_find_chain_entry, xg_get_best_chain_entry)
(xg_order_trampoline_chain, xg_get_trampoline_chain)
(xg_find_best_eq_target, xg_add_location_to_chain)
(xg_create_trampoline_chain, xg_get_single_symbol_slot): New
functions.
(xg_relax_fixups): Call xg_find_best_eq_target to adjust jump
target to point to an existing jump. Call
xg_create_trampoline_chain to create new jump target. Call
xg_add_location_to_chain to add newly created trampoline jump
to the corresponding chain.
(add_jump_to_trampoline): Extract loop searching for a single
slot with a symbol into a separate function, replace that code
with a call to that function.
(relax_frag_immed): Call xg_find_best_eq_target to adjust jump
target to point to an existing jump.
* testsuite/gas/xtensa/all.exp: Add trampoline-2 test.
* testsuite/gas/xtensa/trampoline.d: Adjust absolute addresses
as many duplicate trampoline chains are now coalesced.
* testsuite/gas/xtensa/trampoline.s: Add _nop so that objdump
stays in sync with instruction stream.
* testsuite/gas/xtensa/trampoline-2.l: New test result file.
* testsuite/gas/xtensa/trampoline-2.s: New test source file.

76a493a 2017-11-28 08:14:48 Max Filippov

gas: xtensa: reuse trampoline placement code

There's almost exact copy of the trampoline placement code in the
search_trampolines function that is used for jumps generated for relaxed
branch instructions. Get rid of the duplication and reuse
xg_find_best_trampoline function for that.

gas/
2017-11-27 Max Filippov <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (search_trampolines, get_best_trampoline):
Remove definitions.
(xg_find_best_trampoline_for_tinsn): New function.
(relax_frag_immed): Replace call to get_best_trampoline with a
call to xg_find_best_trampoline_for_tinsn.
* testsuite/gas/xtensa/trampoline.d: Adjust absolute addresses
as the placement of trampolines for relaxed branches has been
changed.

fe6c2f1 2017-11-28 08:13:52 Max Filippov

gas: xtensa: rewrite xg_relax_trampoline

Replace linked list of trampoline frags with an ordered array, so that
instead of indexing fixups trampolines could be indexed. Keep each array
in the trampoline_seg structure, so there's no need to rebuild it for
every new processed segment. Don't run relaxation for each trampoline
frag, instead run it for each fixup in the current segment that needs
relaxation at the beginning of each relaxation pass. This way the
complexity of this process drops from about O(n^2 * m) to about
O(log n * m), where n is the number of trampoline frags and m is the
number of fixups that need relaxation in the segment.

gas/
2017-11-27 Max Filippov <jcmvbkbc@gmail.com>

* config/tc-xtensa.c (trampoline_index): New structure.
(trampoline_seg): Replace trampoline list with trampoline index.
(xg_find_trampoline, xg_add_trampoline_to_index)
(xg_remove_trampoline_from_index, xg_add_trampoline_to_seg)
(xg_is_trampoline_frag_full, xg_get_fulcrum)
(xg_find_best_trampoline, xg_relax_fixup, xg_relax_fixups)
(xg_is_relaxable_fixup): New functions.
(J_MARGIN): New macro.
(xtensa_create_trampoline_frag): Use xg_add_trampoline_to_seg
instead of open-coded addition to the linked list.
(dump_trampolines): Iterate through the trampoline_seg::index.
(cached_fixupS, cached_fixup, fixup_cacheS, fixup_cache)
(fixup_order, xtensa_make_cached_fixup)
(xtensa_realloc_fixup_cache, xtensa_cache_relaxable_fixups)
(xtensa_find_first_cached_fixup, xtensa_delete_cached_fixup)
(xtensa_add_cached_fixup, check_and_update_trampolines): Remove
definitions.
(xg_relax_trampoline): Extract logic into separate functions,
replace body with a call to xg_relax_fixups.
(search_trampolines): Replace search in linked list with search
in index. Change data type of address-tracking variables from
int to offsetT. Replace abs with labs.
(xg_append_jump): Finish the trampoline frag if it's full.
(add_jump_to_trampoline): Remove trampoline frag from the index
if the frag is full.
* config/tc-xtensa.h (xtensa_frag_type): Remove next_trampoline.
* testsuite/gas/xtensa/trampoline.d: Adjust absolute addresses
as the placement of trampolines has slightly changed.
* testsuite/gas/xtensa/trampoline.s: Add _nop so that objdump
stays in sync with instruction stream.