Commit Graph

61 Commits

Author SHA1 Message Date
Nick Clifton ad2a37157d If the lto plugin encounters a file with multiple symbol sections, each of which also has a v1 symbol extension section[1] then it will attempt to read the extension data for *every* symbol from each of the extension sections. This results in reading off the end of a buffer with the associated memory corruption that that entails. This patch fixes that problem.
2020-09-09  Nick Clifton  <nickc@redhat.com>

	* lto-plugin.c (struct plugin_symtab): Add last_sym field.
	(parse_symtab_extension): Only read as many entries as are
	available in the buffer.  Store the data read into the symbol
	table indexed from last_sym.  Increment last_sym.
2020-09-09 15:54:20 +01:00
Alexandre Oliva 1dedc12d18 revamp dump and aux output names
This patch simplifies (!!!) the logic governing the naming of dump
files and auxiliary output files in the driver, in the compiler, and
in the LTO wrapper.  No changes are made to the naming of primary
outputs, there are often ways to restore past behavior, and a number
of inconsistencies are fixed.  Some internal options are removed
(-auxbase and -auxbase-strip), sensible existing uses of -dumpdir and
-dumpbase options remain unchanged, additional useful cases are added,
making for what is still admittedly quite complex.  Extensive
documentation and testcases provide numerous examples, from normal to
corner cases.

The most visible changes are:

- aux and dump files now always go in the same directory, that
defaults to the directory of the primary output, but that can be
overridden with -dumpdir, -save-temps=*, or, preserving past behavior,
with a -dumpbase with a directory component.

- driver and compiler now have the same notion of naming of auxiliary
outputs, e.g. .dwo files will no longer be in one location while the
debug info suggests they are elsewhere, and -save-temps and .dwo
auxiliary outputs now go in the same location as .su, .ci and
coverage data, with consistent naming.

- explicitly-specified primary output names guide not only the
location of aux and dump outputs: the output base name is also used in
their base name, as a prefix when also linking (e.g. foo.c bar.c -o
foobar creates foobar-foo.dwo and foobar-bar.dwo with -gsplit-dwarf),
or as the base name instead of the input name (foo.c -c -o whatever.o
creates whatever.su rather than foo.su with -fstack-usage).  The
preference for the input file base name, quite useful for our
testsuite, can be restored with -dumpbase "".  When compiling and
linking tests in the testsuite with additional inputs, we now use this
flag.  Files named in dejagnu board ldflags, libs, and ldscripts are
now quoted in the gcc testsuite with -Wl, so that they are not counted
as additional inputs by the compiler driver.

- naming a -dumpbase when compiling multiple sources used to cause
dumps from later compiles to overwrite those of earlier ones; it is
now used as a prefix when compiling multiple sources, like an
executable name above.

- the dumpbase, explicitly specified or computed from output or input
names, now also governs the naming of aux outputs; since aux outputs
usually replaced the suffix from the input name, while dump outputs
append their own additional suffixes, a -dumpbase-ext option is
introduced to enable a chosen suffix to be dropped from dumpbase to
form aux output names.

- LTO dump and aux outputs were quite a mess, sometimes leaking
temporary output names into -save-temps output names, sometimes
conversely generating desirable aux outputs in temporary locations.
They now obey the same logic of compiler aux and dump outputs, landing
in the expected location and taking the linker output name or an
explicit dumpbase overrider into account.

- Naming of -fdump-final-insns outputs now follows the dump file
naming logic for the .gkd files, and the .gk dump files generated in
the second -fcompare-debug compilation get the .gk inserted before the
suffix that -dumpbase-ext drops in aux outputs.


gcc/ChangeLog:

	* common.opt (aux_base_name): Define.
	(dumpbase, dumpdir): Mark as Driver options.
	(-dumpbase, -dumpdir): Likewise.
	(dumpbase-ext, -dumpbase-ext): New.
	(auxbase, auxbase-strip): Drop.
	* doc/invoke.texi (-dumpbase, -dumpbase-ext, -dumpdir):
	Document.
	(-o): Introduce the notion of primary output, mention it
	influences auxiliary and dump output names as well, add
	examples.
	(-save-temps): Adjust, move examples into -dump*.
	(-save-temps=cwd, -save-temps=obj): Likewise.
	(-fdump-final-insns): Adjust.
	* dwarf2out.c (gen_producer_string): Drop auxbase and
	auxbase_strip; add dumpbase_ext.
	* gcc.c (enum save_temps): Add SAVE_TEMPS_DUMP.
	(save_temps_prefix, save_temps_length): Drop.
	(save_temps_overrides_dumpdir): New.
	(dumpdir, dumpbase, dumpbase_ext): New.
	(dumpdir_length, dumpdir_trailing_dash_added): New.
	(outbase, outbase_length): New.
	(The Specs Language): Introduce %".  Adjust %b and %B.
	(ASM_FINAL_SPEC): Use %b.dwo for an aux output name always.
	Precede object file with %w when it's the primary output.
	(cpp_debug_options): Do not pass on incoming -dumpdir,
	-dumpbase and -dumpbase-ext options; recompute them with
	%:dumps.
	(cc1_options): Drop auxbase with and without compare-debug;
	use cpp_debug_options instead of dumpbase.  Mark asm output
	with %w when it's the primary output.
	(static_spec_functions): Drop %:compare-debug-auxbase-opt and
	%:replace-exception.  Add %:dumps.
	(driver_handle_option): Implement -save-temps=*/-dumpdir
	mutual overriding logic.  Save dumpdir, dumpbase and
	dumpbase-ext options.  Do not save output_file in
	save_temps_prefix.
	(adds_single_suffix_p): New.
	(single_input_file_index): New.
	(process_command): Combine output dir, output base name, and
	dumpbase into dumpdir and outbase.
	(set_collect_gcc_options): Pass a possibly-adjusted -dumpdir.
	(do_spec_1): Optionally dumpdir instead of save_temps_prefix,
	and outbase instead of input_basename in %b, %B and in
	-save-temps aux files.  Handle empty argument %".
	(driver::maybe_run_linker): Adjust dumpdir and auxbase.
	(compare_debug_dump_opt_spec_function): Adjust gkd dump file
	naming.  Spec-quote the computed -fdump-final-insns file name.
	(debug_auxbase_opt): Drop.
	(compare_debug_self_opt_spec_function): Drop auxbase-strip
	computation.
	(compare_debug_auxbase_opt_spec_function): Drop.
	(not_actual_file_p): New.
	(replace_extension_spec_func): Drop.
	(dumps_spec_func): New.
	(convert_white_space): Split-out parts into...
	(quote_string, whitespace_to_convert_p): ... these.  New.
	(quote_spec_char_p, quote_spec, quote_spec_arg): New.
	(driver::finalize): Release and reset new variables; drop
	removed ones.
	* lto-wrapper.c (HAVE_TARGET_EXECUTABLE_SUFFIX): Define if...
	(TARGET_EXECUTABLE_SUFFIX): ... is defined; define this to the
	empty string otherwise.
	(DUMPBASE_SUFFIX): Drop leading period.
	(debug_objcopy): Use concat.
	(run_gcc): Recognize -save-temps=* as -save-temps too.  Obey
	-dumpdir.  Pass on empty dumpdir and dumpbase with a directory
	component.  Simplify temp file names.
	* opts.c (finish_options): Drop aux base name handling.
	(common_handle_option): Drop auxbase-strip handling.
	* toplev.c (print_switch_values): Drop auxbase, add
	dumpbase-ext.
	(process_options): Derive aux_base_name from dump_base_name
	and dump_base_ext.
	(lang_dependent_init): Compute dump_base_ext along with
	dump_base_name.  Disable stack usage and callgraph-info	during
	lto generation and compare-debug recompilation.

gcc/fortran/ChangeLog:

	* options.c (gfc_get_option_string): Drop auxbase, add
	dumpbase_ext.

gcc/ada/ChangeLog:

	* gcc-interface/lang-specs.h: Drop auxbase and auxbase-strip.
	Use %:dumps instead of -dumpbase.  Add %w for implicit .s
	primary output.
	* switch.adb (Is_Internal_GCC_Switch): Recognize dumpdir and
	dumpbase-ext.  Drop auxbase and auxbase-strip.

lto-plugin/ChangeLog:

	* lto-plugin.c (skip_in_suffix): New.
	(exec_lto_wrapper): Use skip_in_suffix and concat to build
	non-temporary output names.
	(onload): Look for -dumpdir in COLLECT_GCC_OPTIONS, and
	override link_output_name with it.

contrib/ChangeLog:

	* compare-debug: Adjust for .gkd files named as dump files,
	with the source suffix rather than the object suffix.

gcc/testsuite/ChangeLog:

	* gcc.misc-tests/outputs.exp: New.
	* gcc.misc-tests/outputs-0.c: New.
	* gcc.misc-tests/outputs-1.c: New.
	* gcc.misc-tests/outputs-2.c: New.
	* lib/gcc-defs.exp (gcc_adjusted_linker_flags): New.
	(gcc_adjust_linker_flags): New.
	(dg-additional-files-options): Call it.  Pass -dumpbase ""
	when there are additional sources.
	* lib/profopt.exp (profopt-execute): Pass the executable
	suffix with -dumpbase-ext.
	* lib/scandump.exp (dump-base): Mention -dumpbase "" use.
	* lib/scanltranstree.exp: Adjust dump suffix expectation.
	* lib/scanwpaipa.exp: Likewise.
2020-05-26 04:30:15 -03:00
Eric Botcazou 5269b24605 Silence warning in LTO mode on VxWorks
The link phase is always partial (-r) for VxWorks in kernel mode, which
means that it uses incremental LTO linking by default (-flinker-output=rel).
But in this mode the LTO plugin outputs a warning if one of the object files
involved in the link does not contain LTO bytecode, before switching to
nolto-rel mode.  We do not do repeated incremental linking for VxWorks so
silence the warning.

lto-plugin/
	* lto-plugin.c: Document -linker-output-auto-notlo-rel option.
	(linker_output_set): Change type to bool.
	(linker_output_known): Likewise.
	(linker_output_auto_nolto_rel): New variable.
	(all_symbols_read_handler): Take it into account.
	<LDPO_REL>: Do not issue the warning if it is set.
	(process_option): Process -linker-output-auto-notlo-rel.
	(cleanup_handler): Remove unused variable.
	(onload) <LDPT_LINKER_OUTPUT>: Adjust to above type change.
gcc/
	* gcc.c (LTO_PLUGIN_SPEC): Define if not already.
	(LINK_PLUGIN_SPEC): Execute LTO_PLUGIN_SPEC.
	* config/vxworks.h (LTO_PLUGIN_SPEC): Define.
2020-05-05 12:42:22 +02:00
Martin Liska c8429c2aba
API extension for binutils (type of symbols).
* lto-section-in.c: Add ext_symtab.
	* lto-streamer-out.c (write_symbol_extension_info): New.
	(produce_symtab_extension): New.
	(produce_asm_for_decls): Stream also produce_symtab_extension.
	* lto-streamer.h (enum lto_section_type): New section.
	* lto-symtab.h (enum gcc_plugin_symbol_type): New.
	(enum gcc_plugin_symbol_section_kind): Likewise.
	* lto-plugin.c (LTO_SECTION_PREFIX): Rename to ...
	(LTO_SYMTAB_PREFIX): ... this.
	(LTO_SECTION_PREFIX_LEN): Rename to ...
	(LTO_SYMTAB_PREFIX_LEN): ... this.
	(LTO_SYMTAB_EXT_PREFIX): New.
	(LTO_SYMTAB_EXT_PREFIX_LEN): New.
	(LTO_LTO_PREFIX): New.
	(LTO_LTO_PREFIX_LEN): New.
	(parse_table_entry): Fill up unused to zero.
	(parse_table_entry_extension): New.
	(parse_symtab_extension): New.
	(finish_conflict_resolution): Change type
	for resolution.
	(process_symtab): Use new macro name.
	(process_symtab_extension): New.
	(claim_file_handler): Parse also process_symtab_extension.
	(onload): Call new add_symbols_v2.
2020-03-19 16:56:27 +01:00
Jakub Jelinek 8d9254fc8a Update copyright years.
From-SVN: r279813
2020-01-01 12:51:42 +01:00
Iain Sandoe 2e97dfdd54 lto-plugin, removed unused variable
2019-05-15  Iain Sandoe  <iain@sandoe.co.uk>

	* lto-plugin.c (cleanup_handler): Remove unused var.

From-SVN: r271212
2019-05-15 14:10:27 +00:00
Iain Sandoe c101cff86e lto-plugin - support -save-temps, -v, --version.
This patch makes the lto-plugin follow the same approach
to save-temps as collect2. 

-save-temps causes the temp file to be named meaningfully,
and for the relevant input files to be saved in CWD.

-v, —version causes the save actions to be output to stderr.

one can get this to happen by just putting -save-temps, -v on
the regular link line or (for compatibility with the way the
 -debug flag works) by appending -plugin-opt=-save-temps, etc.

lto-plugin/

2019-05-15  Iain Sandoe  <iain@sandoe.co.uk>

	* lto-plugin.c (exec_lto_wrapper): Make the wrapper
	arguments filename more user-friendly.
	(file_exists, maybe_unlink): New.
	(cleanup_handler): Use maybe unlink to handle the
	case when temps should be saved.
	(process_option): Look for -v, —-version, -save-temps.
	(onload): Record the linker output file name.
	Check for -v, —-version, -save-temps in the GCC collect
	options environment.

From-SVN: r271202
2019-05-15 09:12:21 +00:00
Jakub Jelinek a554497024 Update copyright years.
From-SVN: r267494
2019-01-01 13:31:55 +01:00
Jan Hubicka de54061dcc lto-plugin.c: (non_claimed_files): New static var.
* lto-plugin.c: (non_claimed_files): New static var.
	(linker_ouput_known): New static var.
	(all_symbols_read_handler): When user specifies linker output do not
	imply it; output warning when nonlto-rel mode is forced.
	(claim_file_header): Record number of nonclaimed files.
	(process_option): Remember if linker output is known

From-SVN: r260960
2018-05-30 16:34:54 +00:00
Jakub Jelinek 85ec4feb11 Update copyright years.
From-SVN: r256169
2018-01-03 11:03:58 +01:00
Georg-Johann Lay 5c2dee6fc9 re PR lto/81487 ([mingw32] ld.exe: error: asprintf failed)
lto-plugin/
	PR lto/81487
	* lto-plugin.c (claim_file_handler): Use xasprintf instead of
	asprintf.
	[hi!=0]: Swap hi and lo arguments supplied to xasprintf.

From-SVN: r250428
2017-07-21 15:58:14 +00:00
Jakub Jelinek 2afd3180c5 Update copyright years.
From-SVN: r244052
2017-01-04 12:30:51 +01:00
Ilya Verbin e6861a99f8 re PR driver/68463 (Offloading fails when some objects are compiled with LTO and some without)
gcc/
	PR driver/68463
	* config/gnu-user.h (CRTOFFLOADBEGIN): Define.  Add crtoffloadbegin.o if
	offloading is enabled and -fopenacc or -fopenmp is specified.
	(CRTOFFLOADEND): Likewise.
	(GNU_USER_TARGET_STARTFILE_SPEC): Add CRTOFFLOADBEGIN.
	(GNU_USER_TARGET_ENDFILE_SPEC): Add CRTOFFLOADEND.
	* lto-wrapper.c (offloadbegin, offloadend): Remove static vars.
	(offload_objects_file_name): New static var.
	(tool_cleanup): Remove offload_objects_file_name file.
	(find_offloadbeginend): Replace with ...
	(find_crtoffloadtable): ... this.
	(run_gcc): Remove offload_argc and offload_argv.
	Get offload_objects_file_name from -foffload-objects=... option.
	Read names of object files with offload from this file, pass them to
	compile_images_for_offload_targets.  Don't call find_offloadbeginend and
	don't pass offloadbegin and offloadend to the linker.  Don't pass
	offload non-LTO files to the linker, because now they're not claimed.
libgcc/
	PR driver/68463
	* Makefile.in (crtoffloadtable$(objext)): New rule.
	* configure.ac (extra_parts): Add crtoffloadtable$(objext) if
	enable_offload_targets is not empty.
	* configure: Regenerate.
	* offloadstuff.c: Move __OFFLOAD_TABLE__ from crtoffloadend to
	crtoffloadtable.
libgomp/
	PR driver/68463
	* testsuite/libgomp.oacc-c-c++-common/parallel-dims-2.c: Remove.
lto-plugin/
	PR driver/68463
	* lto-plugin.c (struct plugin_offload_file): New.
	(offload_files): Change type.
	(offload_files_last, offload_files_last_obj): New.
	(offload_files_last_lto): New.
	(free_2): Adjust accordingly.
	(all_symbols_read_handler): Don't add offload files to lto_arg_ptr.
	Don't call free_1 for offload_files.  Write names of object files with
	offloading to the temporary file.  Add new option to lto_arg_ptr.
	(claim_file_handler): Don't claim file if it contains offload sections
	without LTO sections.  If it contains offload sections, add to the list.

From-SVN: r233712
2016-02-25 12:23:52 +00:00
Martin Liska aea40b0877 Fix usage of an uninitialized variable
* lto-plugin.c (all_symbols_read_handler): Assign default
	value to a string variable.

From-SVN: r232426
2016-01-15 14:39:11 +00:00
Jan Hubicka 1ff9ed6fb2 re PR lto/67548 (LTO drops weak binding with "ld -r")
PR lto/67548
	* lto-plugin.c (linker_output, linker_output_set): New statics.
	(all_symbols_read_handler): Add -flinker-output option.
	(onload): Record linker_output info.

	* ipa-visibility.c (cgraph_externally_visible_p,
	varpool_node::externally_visible_p): When doing incremental linking,
	hidden symbols may be still used later.
	(update_visibility_by_resolution_info): Do not drop weak during
	incremental link.
	(function_and_variable_visibility): Fix formating.
	* flag-types.h (lto_linker_output): Declare.
	* common.opt 9flag_incremental_link): New flag.

	* lto-lang.c (lto_post_options): Process flag_lto_linker_output.
	* lang.opt (lto_linker_output): New enum.
	(flinker_output): New flag.

From-SVN: r230915
2015-11-25 23:05:07 +00:00
H.J. Lu 514ba9e4ad Revert the PR lto/64837 fix
It breaks gold:

% echo "int main () {}" | gcc -fuse-ld=gold -flto -x c++ -
ld.gold: internal error in remove_writer, at token.h:132
collect2: error: ld returned 1 exit status

	* lto-plugin.c (release_input_file): Removed.
	(claim_file_handler): Don't call release_input_file.
	(onload): Don't set release_input_file.

From-SVN: r220477
2015-02-06 05:55:42 -08:00
H.J. Lu 11c17039dd Pass handle to release_input_file
* lto-plugin.c (claim_file_handler): Pass handle to
	release_input_file.

From-SVN: r220461
2015-02-05 12:56:14 -08:00
H.J. Lu 06fa4f005f Call release_input_file only if file is claimed
* lto-plugin.c (claim_file_handler): Call release_input_file only
	if file is claimed.

From-SVN: r220455
2015-02-05 08:40:44 -08:00
H.J. Lu 380c25ea45 Call release_input_file only if not NULL
* lto-plugin.c (claim_file_handler): Call release_input_file only
	if it is not NULL.

From-SVN: r220224
2015-01-28 15:59:55 -08:00
H.J. Lu 1e081edaad Call release_input_file in claim_file_handler
PR lto/64837
	* lto-plugin.c (release_input_file): New.
	(claim_file_handler): Call release_input_file.
	(onload): Set release_input_file.

From-SVN: r220212
2015-01-28 11:39:42 -08:00
Ilya Verbin 443743fd95 lto-wrapper.c (compile_offload_image): Start processing in_argv from 0 instead of 1.
gcc/
	* lto-wrapper.c (compile_offload_image): Start processing in_argv
	from 0 instead of 1.
	(run_gcc): Put offload objects into offload_argv, put LTO objects and
	possible preceding arguments into lto_argv.
	Pass offload_argv to compile_images_for_offload_targets instead of argv.
	Use lto_argv for LTO recompilation instead of argv.
lto-plugin/
	* lto-plugin.c (offload_files, num_offload_files): New static variables.
	(free_1): Use arguments instead of global variables.
	(free_2): Free offload_files.
	(all_symbols_read_handler): Add names from offload_files to lto-wrapper
	arguments.
	(claim_file_handler): Do not add file to claimed_files if it contains
	offload sections without LTO sections.  Add it to offload_files instead.

From-SVN: r218543
2014-12-09 22:44:16 +00:00
Ilya Verbin fc8b3540d2 [PATCH 4/7] OpenMP 4.0 offloading infrastructure: lto-wrapper.
gcc/
	* gcc.c (spec_host_machine, accel_dir_suffix): New variables.
	(process_command): Tweak path construction for the possibility
	of being configured as an offload compiler.
	(driver::maybe_putenv_OFFLOAD_TARGETS): New function.
	(driver::main): Call maybe_putenv_OFFLOAD_TARGETS.
	(driver::set_up_specs): Tweak path construction for the possibility of
	being configured as an offload compiler.
	* lto-wrapper.c (OFFLOAD_TARGET_NAMES_ENV): Define.
	(offload_names, offloadbegin, offloadend): New static variables.
	(free_array_of_ptrs, parse_env_var, access_check, compile_offload_image)
	(compile_images_for_offload_targets, copy_file, find_offloadbeginend):
	New static functions.
	(run_gcc): Determine whether offload sections are present.  If so, run
	compile_images_for_offload_targets and return the names of new generated
	objects to linker.  If there are offload sections, but no LTO sections,
	then return the copies of input objects without link-time recompilation.

lto-plugin/
	* lto-plugin.c (OFFLOAD_SECTION, OFFLOAD_SECTION_LEN): Define.
	(struct plugin_objfile): Add new field "offload".
	(process_offload_section): New static function.
	(claim_file_handler): Claim file if it contains offload sections.

Co-Authored-By: Andrey Turetskiy <andrey.turetskiy@intel.com>
Co-Authored-By: Bernd Schmidt <bernds@codesourcery.com>
Co-Authored-By: Michael Zolotukhin <michael.v.zolotukhin@intel.com>

From-SVN: r217491
2014-11-13 13:47:46 +00:00
Richard Biener 21b624f069 lto-plugin.c (onload): Fail to load if -fno-use-linker-plugin is set in COLLECT_GCC_OPTIONS.
2014-04-02  Richard Biener  <rguenther@suse.de>

	* lto-plugin.c (onload): Fail to load if -fno-use-linker-plugin
	is set in COLLECT_GCC_OPTIONS.

From-SVN: r209011
2014-04-02 08:25:13 +00:00
Richard Biener 2486c24a8c simple-object.c (simple_object_internal_read): Handle EINTR and short reads.
2014-03-28  Richard Biener  <rguenther@suse.de>

	libiberty/
	* simple-object.c (simple_object_internal_read): Handle
	EINTR and short reads.

	lto-plugin/
	* lto-plugin.c (process_symtab): Handle EINTR and short reads.

From-SVN: r208898
2014-03-28 14:05:49 +00:00
Joseph Myers 3f417959fd * lto-plugin.c: Fix typo.
From-SVN: r187982
2012-05-29 20:21:25 +01:00
Kai Tietz 8cfa78994a re PR lto/50616 (lto1.exe: internal compiler error: invalid resolution in the resolution file)
PR lto/50616
        * lto-plugin.c (PRI_LL): New macro.
        (dump_symtab): Use PRI_LL instead of ll in print.
        (process_symtab): Use PRI_LL instead of ll in scan.

From-SVN: r184462
2012-02-22 11:19:22 +01:00
Jan Hubicka ed0d2da02b re PR lto/47247 (Linker plugin specification makes it difficult to handle COMDATs)
PR lto/47247
	* lto-plugin.c (get_symbols_v2): New variable.
	(write_resolution): Use V2 API when available.
	(onload): Handle LDPT_GET_SYMBOLS_V2.

	* lto-symtab.c (lto_symtab_resolve_symbols): Do not resolve
	when resolution is already availbale from plugin.
	(lto_symtab_merge_decls_1): Handle LDPR_PREVAILING_DEF_IRONLY_EXP.
	* cgraph.c (ld_plugin_symbol_resolution): Add prevailing_def_ironly_exp.
	* lto-cgraph.c (LDPR_NUM_KNOWN): Update.
	* ipa.c (varpool_externally_visible_p): IRONLY variables are never
	externally visible.
	* varasm.c (resolution_to_local_definition_p): Add
	LDPR_PREVAILING_DEF_IRONLY_EXP.
	(resolution_local_p): Likewise.

	* common.c (lto_resolution_str): Add new resolution.
	* common.h (lto_resolution_str): Likewise.

From-SVN: r179424
2011-10-02 10:41:24 +00:00
H.J. Lu ad7715f324 Use 64bit integer for LTO symbol ID.
gcc/lto

2011-09-30  H.J. Lu  <hongjiu.lu@intel.com>
	    Andi Kleen  <ak@linux.intel.com>

	PR lto/50568
	* lto.c (lto_splay_tree_delete_id): New.
	(lto_splay_tree_compare_ids): Likewise.
	(lto_splay_tree_lookup): Likewise.
	(lto_splay_tree_id_equal_p): Likewise.
	(lto_splay_tree_insert): Likewise.
	(lto_splay_tree_new): Likewise.
	(lto_resolution_read): Change id to unsigned HOST_WIDE_INT.
	Use lto_splay_tree_id_equal_p and lto_splay_tree_lookup.
	(create_subid_section_table): Use lto_splay_tree_lookup and
	lto_splay_tree_insert.
	(lto_file_read): Use lto_splay_tree_new.

lto-plugin/

2011-09-30  H.J. Lu  <hongjiu.lu@intel.com>
	    Andi Kleen  <ak@linux.intel.com>

	PR lto/50568
	* lto-plugin.c (sym_aux): Change id to unsigned long long.
	(plugin_symtab): Likewise.
	(dump_symtab): Likewise.
	(resolve_conflicts): Likewise.
	(process_symtab): Likewise.

Co-Authored-By: Andi Kleen <ak@linux.intel.com>

From-SVN: r179395
2011-09-30 08:48:51 -07:00
Jim Meyering 046957830e remove useless if-before-free tests
Change "if (E) free (E);" to "free (E);" everywhere except in the
libgo/, intl/, zlib/ and classpath/ directories.
Also transform equivalent variants like
"if (E != NULL) free (E);" and allow an extra cast on the
argument to free.  Otherwise, the tested and freed "E"
expressions must be identical, modulo white space.

From-SVN: r172785
2011-04-20 18:19:03 +00:00
Richard Guenther 3b8c1a3f49 re PR lto/48431 (patch to fix a compile error in lto-plugin.c when using older C compilers)
2011-04-05  Richard Guenther  <rguenther@suse.de>

	PR bootstrap/48431
	* lto-plugin.c (claim_file_handler): Do not declare vars in code.

From-SVN: r171982
2011-04-05 12:11:08 +00:00
Ian Lance Taylor e3bb089d5f lto-plugin.c (gold_version): New static variable.
* lto-plugin.c (gold_version): New static variable.
	(all_symbols_read_handler): Don't check pass_through_items if
	using gold 1.11 or later.
	(onload): Set gold_version if we see LDPT_GOLD_VERSION.

From-SVN: r169237
2011-01-25 15:29:02 +00:00
Richard Guenther 47782a9d27 re PR lto/47264 (Many tests fail with -flto due unaligned load in lto-plugin.c)
2011-01-12  Richard Guenther  <rguenther@suse.de>

	PR lto/47264
	* lto-plugin.c (parse_table_entry): Use memcpy to access
	unaligned fields.

From-SVN: r168708
2011-01-12 12:04:39 +00:00
Dave Korn 77754180a9 re PR middle-end/46674 (Weak alias is mistakenly optimized away)
gcc/ChangeLog:

	PR middle-end/46674
	PR lto/43157
	* target.def (mangle_assembler_name): New target asm_out hook.
	* targhooks.c (default_mangle_assembler_name): Add default hook
	implementation.
	* targhooks.h (default_mangle_assembler_name): Add prototype.
	* lto-symtab.c (lto_symtab_register_decl): Use new hook when
	processing DECL_ASSEMBLER_NAMEs for lto symtabs.
	(lto_symtab_get_resolution): Likewise.
	(lto_cgraph_replace_node): Likewise.
	(lto_symtab_prevailing_decl): Likewise.
	* lto-streamer-out.c (write_symbol): Likewise.
	* doc/tm.texi.in (TARGET_MANGLE_ASSEMBLER_NAME): Add @hook directive.
	* doc/tm.texi: Regenerate.
	* config/i386/cygming.h (TARGET_MANGLE_ASSEMBLER_NAME): Define to
	point at i386_pe_mangle_assembler_name.
	* config/i386/winnt.c (i386_pe_mangle_assembler_name): New function.
	* config/i386/i386-protos.h (i386_pe_mangle_assembler_name): Add
	prototype.

lto-plugin/ChangeLog:

	PR middle-end/46674
	PR lto/43157
	* configure.ac (SYM_STYLE): Don't AC_DEFINE.
	* lto-plugin.c (sym_style): Don't use it; default to ss_none.
	* configure: Regenerate.
	* config.h.in: Likewise.

gcc/testsuite/ChangeLog:

	PR middle-end/46674
	PR lto/43157
	* gcc.dg/pr43157.c: New file.

From-SVN: r167688
2010-12-10 14:28:58 +00:00
Kai Tietz ec692d5f10 config.h.in: Regenerated.
2010-12-05  Kai Tietz  <kai.tietz@onevision.com>

        * config.h.in: Regenerated.
        * configure: Regenerated.
        * configure.ac (AC_CHECK_HEADERS): Replaced by AC_HEADER_SYS_WAIT.
        * lto-plugin.c (WIFEXITED): Define default.
        (WEXITSTATUS): Likeiwse.

From-SVN: r167468
2010-12-05 09:06:25 +01:00
Kai Tietz a2254c5d78 config.h.in: Regenerated.
2010-12-01  Kai Tietz  <kai.tietz@onevision.com>

        * config.h.in: Regenerated.
        * configure: Regenerated.
        * Makefile.in: Regenerated.
        * configure.ac (AC_CHECK_HEADERS): Check for sys/wait.h.
        * lto-plugin.c:  Include sys/wait.h conditionally.
        * aclocal.m4: Regenerated.

From-SVN: r167343
2010-12-01 17:57:47 +01:00
Kai Tietz 44538c626c lto-plugin.c (add_output_files): Fix memory leak.
2010-11-13  Kai Tietz  <kai.tietz@onevision.com>

        * lto-plugin.c (add_output_files): Fix memory leak.

From-SVN: r166718
2010-11-13 19:49:07 +01:00
Dave Korn d19e0f01a1 re PR bootstrap/46397 (lto-plugin.c does not build on Solaris 10/SPARC)
PR bootstrap/46397
	PR bootstrap/46362
	* configure.ac: Add AC_TYPE_INT64_T test.
	* config.h.in: Regenerate.
	* configure: Likewise.
	* lto-plugin.c (debug): Use char not bool.
	(nop): Likewise.
	(check_1): Rename from check, and use int not bool for gate argument.
	(check): Macro wrapper for the above to coerce gate argument into
	boolean-valued integer in case it has pointer type.
	(parse_table_entry): Use 0 not false.
	(claim_file_handler): Avoid use of PRIx64 by splitting 64-bit size
	into two 32-bit parts and printing as hex ints.

From-SVN: r166601
2010-11-11 13:33:59 +00:00
Dave Korn 37da368856 re PR lto/46291 (Failed to bootstrap-lto)
PR lto/46291
	* lto-plugin.c (claim_file_handler): Don't close file descriptor.

From-SVN: r166285
2010-11-03 23:13:51 +00:00
Dave Korn 48215350c2 re PR lto/46273 (Failed to bootstrap)
ChangeLog:

2010-11-03  Ian Lance Taylor  <iant@google.com>
	    Dave Korn  <dave.korn.cygwin@gmail.com>

	PR lto/46273
	* configure.ac: Remove libelf tests.  Build lto-plugin on ELF always
	and on other supported platforms whenever LTO is enabled.
	* configure: Rebuild.

gcc/ChangeLog:

2010-11-03  Ian Lance Taylor  <iant@google.com>

	PR lto/46273
	* gcc/config.gcc: Don't set lto_binary_reader.
	* doc/install.texi (Prerequisites): Remove libelf paragraphs.
	(Configuration): Mention --disable-lto.  Remove --with-libelf
	paragraph.

lto-plugin/ChangeLog:

2010-11-03  Dave Korn  <dave.korn.cygwin@gmail.com>

	PR lto/46273
	* lto-plugin.h: Delete.
	* lto-plugin-elf.c: Likewise.
	* lto-plugin-coff.c: Likewise.
	* configure.ac: Don't use libelf, don't source config.gcc.
	(LIBELFLIBS): Delete.
	(LIBELFINC): Delete.
	(LTO_FORMAT): Delete.
	(SYM_STYLE): Add AC_DEFINE var, set based on $target.
	(config.h): Add AC_CONFIG_HEADERS directive.
	* Makefile.am (LIBELFLIBS): Delete.
	(LIBELFINC): Delete.
	(LTO_FORMAT): Delete.
	(DEFS): Import.
	(AM_CPPFLAGS): Use it.  Don't use LIBELFINC.
	(liblto_plugin_la_SOURCES): Don't use LTO_FORMAT, don't include
	any object-format-specific source file in the link.
	(liblto_plugin_la_LIBADD): Don't use LIBELFLIBS.
	* config.h.in: Generate.
	* configure: Regenerate.
	* Makefile.in: Likewise.
	* lto-plugin.c (O_BINARY): Definition moved here from lto-plugin.h.
	(LTO_SEGMENT_NAME): New definition.
	(LTO_SECTION_PREFIX): Definition moved here from lto-plugin.h.
	(LTO_SECTION_PREFIX_LEN): New definition.
	(struct sym_aux): Struct definition moved here from lto-plugin.h.
	(struct plugin_symtab): Likewise.
	(struct plugin_objfile): Likewise.
	(struct plugin_objfile): New struct def.
	(enum symbol_style): New enum type.
	(add_symbols): Make static.
	(claimed_files): Likewise.
	(num_claimed_files): Likewise.
	(sym_style): New global.
	(check): Make static.
	(parse_table_entry): Likewise.  Respect sym_style when extracting
	symbol from symtab entry.
	(translate): Make static.
	(resolve_conflicts): Likewise.
	(process_symtab): New function, per-section callback version of
	old object-format-specific handling from deleted lto-plugin-elf.c.
	(claim_file_handler): Convert ELF-specific version from deleted
	lto-plugin-elf.c to simple_object interface and move here.
	(process_options): Allow new '-sym-style=' option.
	(onload): Don't call deleted onload_format_checks hook.

From-SVN: r166233
2010-11-03 09:14:32 +00:00
Kai Tietz 9df2493c38 lto-plugin.c (dump_symtab): Correct printf argument type.
2010-10-11  Kai Tietz  <kai.tietz@onevision.com>

        * lto-plugin.c (dump_symtab): Correct printf argument type.
        (finish_conflict_resolution): Initialize resolution.

From-SVN: r165310
2010-10-11 16:14:54 +02:00
Dave Korn 1cd0b7167e configure.ac (build_lto_plugin): New shell variable.
ChangeLog:

2010-10-07  Dave Korn  <dave.korn.cygwin@gmail.com>

	* configure.ac (build_lto_plugin): New shell variable.
	(--enable-lto): Turn on by default for all non-ELF platforms that
	have had LTO support added so far.  Set build_lto_plugin appropriately
	for both ELF and non-ELF.
	(configdirs): Add lto-plugin or not based on build_lto_plugin.
	* configure: Regenerate.

gcc/ChangeLog:

2010-10-07  Dave Korn  <dave.korn.cygwin@gmail.com>

	* config.host (host_lto_plugin_soname): New shell variable.
	* configure.ac (LTOPLUGINSONAME): Add an AC_DEFINE for the above.
	* config.in: Regenerate.
	* configure: Regenerate.
	* gcc.c (main): Use LTOPLUGINSONAME instead of hard-coding name of
	LTO plugin shared library.

lto-plugin/ChangeLog:

2010-10-07  Dave Korn  <dave.korn.cygwin@gmail.com>

	* configure.ac: Source config.gcc to determine lto_binary_reader.
	(LTO_FORMAT): New AC_SUBST variable inferred from lto_binary_reader.
	* Makefile.am (LTO_FORMAT): Import.
	(liblto_plugin_la_SOURCES): Add object format dependent module
	defined by LTO_FORMAT.
	(liblto_plugin_la_LIBADD): Allow for both PIC and non-PIC libiberty,
	and work around libtool warning.
	* configure: Regenerate.
	* Makefile.in: Likewise.
	* lto-plugin.c (struct sym_aux): Move to new lto-plugin.h.
	(struct sym_aux): Likewise.
	(struct plugin_symtab): Likewise.
	(struct plugin_file_info): Likewise.
	(LTO_SECTION_PREFIX): Likewise.
	(add_symbols):  Make non-static.
	(claimed_files): Likewise.
	(num_claimed_files): Likewise.
	(check): Likewise.
	(parse_table_entry): Likewise.
	(translate): Likewise.
	(resolve_conflicts): Likewise.
	(process_symtab): Move to new lto-plugin-elf.c object format dependent
	source file.
	(claim_file_handler): Likewise, and make non-static.
	(onload): Call new onload_format_checks function.
	* lto-plugin.h: New file.
	(LTO_SECTION_PREFIX): Move here.
	(struct sym_aux): Likewise.
	(struct plugin_symtab): Likewise.
	(struct plugin_file_info): Likewise.
	(claim_file_handler): Add new function prototype.
	(onload_format_checks): Likewise.
	(check): Declare extern.
	(translate): Likewise.
	(parse_table_entry): Likewise.
	(resolve_conflicts): Likewise.
	(add_symbols):  Likewise.
	(claimed_files): Likewise.
	(num_claimed_files): Likewise.
	* lto-plugin-elf.c (process_symtab): Move here.
	(claim_file_handler): Likewise, and make non-static.
	(onload_format_checks): New function factored out from onload.
	* lto-plugin-coff.c (claim_file_handler): New function stub.
	(onload_format_checks): Likewise.

From-SVN: r165133
2010-10-07 20:28:59 +00:00
Andi Kleen d2c57fe97e lto-plugin.c: Include <hashtab.h>
* lto-plugin.c: Include <hashtab.h>
        (sym_aux): Add next_conflict field to save conflict chains.
        (plugin_file_info): Add conflicts symtab.
        (parse_table_entry): Initialize aux->next_conflict.
        (process_symtab): Increment found.
        (dump_symtab): Add.
        (finish_conflict_resolution): Add.
        (free_symtab): Add.
        (write_resolution): Remove symbols loop and move into
        dump_symtab. Call dump_symtab for main symbol and conflicts table.
        Call free_symtab to free conflicts table.
        (SWAP): Add.
        (eq_sym): Add.
        (hash_sym): Add.
        (symbol_strength): Add.
        (resolve_conflicts): Add.
        (claim_file_handler): Add n variable. Check return value of
        process_symtab. Call resolve_conflicts.

From-SVN: r162915
2010-08-05 14:25:45 +00:00
Andi Kleen ba4141f488 lto-plugin.c (translate): Remove debug fprintf.
* lto-plugin.c (translate): Remove debug fprintf.

From-SVN: r162630
2010-07-28 14:05:39 +00:00
H.J. Lu 9477ccb2b1 Cast to unsigned long.
2010-07-23  H.J. Lu  <hongjiu.lu@intel.com>

	PR bootstrap/45042
	* lto-plugin.c (translate): Cast to unsigned long.

From-SVN: r162465
2010-07-23 07:37:21 -07:00
Andi Kleen 73ce4d1ed6 re PR lto/44992 (ld -r breaks LTO)
gcc:

2010-07-10   Andi Kleen <ak@linux.intel.com>

        PR lto/44992
        * lto-opts.c (lto_write_options): Add NULL file_data argument to 
	lto_get_section_name.
	* lto-section-out.c (lto_destroy_simple_output_block): Likewise.
	* lto-streamer-out.c (produce_asm): Likewise.
	(copy_function): Likewise.
	(produce_symtab): Likewise.
	(produce_asm_for_decls): Likewise.
	* lto-streamer.c (lto_get_section_name): Add file_data argument.	
	Rewrite to add random postfix to LTO sections.
	* lto-streamer.h (lto_file_decl_data): Add next, id, resolutions.
	(lto_get_section_name): Add file_data argument to prototype.
	

lto:

2010-07-10   Andi Kleen <ak@linux.intel.com>

        PR lto/44992
        * lto.c: Include splay-tree.h
	(lto_resolution_read): Change to walk file_ids tree and parse
	extra file_id in resolution file.
	(lto_section_with_id): Add.
	(create_subid_section_table): Add.
	(lwstate): Add.
	(lto_create_files_from_ids): Add.
	(lto_file_read): Change to handle sub file ids and create list
	of file_datas. Add output argument for count.
	(get_section_data): Pass file_data to lto_get_section_name.
	(lto_flatten_file): Add.
	(read_cgraph_and_symbols): Handle linked lists of file_datas.
	
lto-plugin:

2010-07-10   Andi Kleen <ak@linux.intel.com>

        PR lto/44992
        * lto-plugin.c (sym_aux): Add.
	(plugin_symtab): Remove slots. Add aux and id.
	(parse_table_entry): Change to use aux instead of slots.
	(LTO_SECTION_PREFIX): Add.
	(translate): Improve buffer allocation. Change to append
	symbols to existing out buffer.
	(get_section): Remove.
	(process_symtab): Add. 
	(free_2): Free symtab->aux.
	(write_resolution): Handle aux instead of slots.
	Print sub id to resolution file.
	(claim_file_handler): Clear lto_file. Replace get_symtab/translate
	calls with call to process_symtab.

From-SVN: r162443
2010-07-23 05:33:51 +00:00
Richard Guenther bdc89f9eff lto-plugin.c (write_resolution): Do not assert syms is non-NULL.
2010-05-21  Richard Guenther  <rguenther@suse.de>

	* lto-plugin.c (write_resolution): Do not assert syms is non-NULL.

From-SVN: r159676
2010-05-21 16:08:28 +00:00
Richard Guenther 5cd0e96b0e re PR lto/43857 (-fresolution causes an ICE)
2010-05-07  Richard Guenther <rguenther@suse.de>

	* gcc.c (LINK_COMMAND_SPEC): Provide a resolution file to
	the linker plugin.
	(store_arg): Queue temp_filename for deletion instead of
	the whole argument.

	lto/
	PR lto/43857
	PR lto/43371
	* lang.opt (fresolution): Change to ...
	(fresolution=): ... this.
	* lto-lang.c (lto_handle_option): Adjust.

	lto-plugin/
	* lto-plugin.c (free_2): Do not free resolution_file.
	(write_resolution): Check that we were passed a resolution file.
	(all_symbols_read_handler): Adjust.
	(cleanup_handler): Do not remove the resolution file.
	(process_option): Handle -fresolution=.

From-SVN: r159159
2010-05-07 15:53:40 +00:00
Richard Guenther ed0f0c0f24 re PR lto/41550 (Fix security and portability issues in lto-plugin)
2010-04-23  Richard Guenther  <rguenther@suse.de>

	PR lto/41550
	* lto-plugin.c (parse_table_entry): Use xstrdup and xrealloc.
	(translate): Likewise.
	(all_symbols_read_handler): Likewise.
	(claim_file_handler): Likewise.
	(process_option): Likewise.
	(add_output_files): Likewise.  Remove filename length limit.

From-SVN: r158673
2010-04-23 15:49:10 +00:00
Dmitry Gorbachev a8a5ac4834 Delete temporary output files.
2010-03-16  Dmitry Gorbachev  <d.g.gorbachev@gmail.com>

	PR lto/43336
	* lto-plugin.c (cleanup_handler): Delete temporary output files.

From-SVN: r157483
2010-03-16 07:06:40 -07:00
H.J. Lu f0d61983a5 Pass -m* and -v to -plugin-opt
gcc/

2010-01-03  H.J. Lu  <hongjiu.lu@intel.com>

	PR lto/42520
	* gcc.c (LINK_COMMAND_SPEC): Pass -m* and -v to -plugin-opt.

lto-plugin/

2010-01-03  H.J. Lu  <hongjiu.lu@intel.com>

	PR lto/42520
	* lto-plugin.c (exec_lto_wrapper): Output lto-wrapper command
	if -v is passed.

From-SVN: r155601
2010-01-03 16:52:50 -08:00