HPUX has a different .comm syntax, and anything in the first column
is a label.
gas/
* testsuite/gas/elf/strtab.s: Don't put directives on first
column or continuation with labels not in first column.
ld/
* testsuite/ld-elf/elf.exp: Xfail pr20995 tests on hppa64-hpux.
Set up HPUX defsym. Run pr14170 tests and build symbol3 objects,
defining HPUX where necessary. Define HPUX for implib tests.
* testsuite/ld-elf/comm-data4.d: Run for hpux.
* testsuite/ld-elf/endsym.d: Likewise.
* testsuite/ld-elf/linkoncerdiff.d: Likewise.
* testsuite/ld-elf/comm-data4.s: Add alternate .comm when HPUX.
* testsuite/ld-elf/comm-data5.s: Likewise.
* testsuite/ld-elf/endsym.s: Likewise.
* testsuite/ld-elf/pr14170c.s: Likewise.
* testsuite/ld-elf/symbol3.s: Likewise.
* testsuite/ld-elf/implib.s: Likewise. Don't start directives
in first column.
* testsuite/ld-elf/linkoncerdiff2.s: Don't use numeric labels.
* testsuite/ld-elf/warn3.d: Run for hpux.
* testsuite/ld-scripts/rgn-at10.d: Xfail for hpux.
* testsuite/ld-scripts/rgn-at11.d: Likewise.
* testsuite/ld-scripts/size-2.d: Remove xfail for hpux.
I misunderstood the hppa alias problem. File offsets of segments need
to be such that no page is mapped twice with different permissions.
(Which still seems to me like something the kernel could fix, but
anyhow, this is not so difficult to achieve in ld.)
PR 21000
bfd/
* elf-bfd.h (struct elf_backend_data): Add no_page_alias.
* elfxx-target.h (elf_backend_no_page_alias): Define.
(elfNN_bed): Init new field.
* elf.c (assign_file_positions_for_load_sections): If no_page_alias
ensure PT_LOAD segment starts on a new page.
* elf32-hppa.c (elf_backend_no_page_alias): Define.
ld/
* testsuite/ld-elf/loadaddr1.d: Adjust for hppa file offsets.
* testsuite/ld-elf/loadaddr2.d: Likewise.
* testsuite/ld-elf/loadaddr3a.d: Likewise.
* testsuite/ld-scripts/rgn-at5.d: Likewise.
Many of the ld tests are not run for cross builds, in some cases
because the test needs to run a newly linked executable, and in others
simply because it was easier to write the test for native only. Even
when a test needs to run, it's good to compile and link to exercise
the linker. So that's what this patch does. I've also rid us of
the old ld_link procedure with all the HOSTING_CRT0 etc. setup. It's
much simpler to just link with $CC.
This does mean that a cross build with cross-compiler installed but
no cross C-library will give lots of failures. If that turns out to
be too annoying, I guess we can write a tcl procedure to detect it and
not run all the extra tests.
* Makefile.am (bootstrap): Delete rule.
(ld-partial, ld1, ld1-full, ld2, ld3): Likewise.
(HOSTING_CRT0, HOSTING_SCRT0): Don't define.
(HOSTING_LIBS, HOSTING_SLIBS, HOSTING_EMU): Likewise.
* configure.ac (HOSTING_CRT0, HOSTING_SCRT0): Don't define.
(HOSTING_LIBS, HOSTING_SLIBS): Likewise.
* configure.host (HOSTING_CRT0, HOSTING_LIBS): Don't define.
* Makefile.in: Regenerate.
* configure: Regenerate.
* testsuite/config/default.exp (get_link_files): Delete.
(HOSTING_CRT0, HOSTING_SCRT0, HOSTING_LIBS, HOSTING_SLIBS): Don't
define.
(ld_simple_link): Delete.
* testsuite/lib/ld-lib.exp (default_ld_link): Delete
(default_ld_simple_link): Rename to default_ld_link.
(ld_simple_link_defsyms): Rename to ld_link_defsyms.
(run_ld_link_tests): Use ld_link, not ld_simple_link.
(run_cc_link_tests): Likewise.
(run_ld_link_exec_tests): Use $CC or $CXX to link, not $ld.
Don't run exe when not native, and return unsupported.
* testsuite/ld-bootstrap/bootstrap.exp: Create gccld1 etc. dirs.
Link ld1 etc. using $CC.
* testsuite/ld-cdtest/cdtest.exp: Link cdtest using $CC.
* testsuite/ld-checks/checks.exp: Use ld_link, not ld_simple_link.
* testsuite/ld-cygwin/exe-export.exp: Likewise.
* testsuite/ld-elf/binutils.exp: Likewise.
* testsuite/ld-elf/eh-group.exp: Likewise.
* testsuite/ld-elf/exclude.exp: Likewise.
* testsuite/ld-elf/frame.exp: Likewise.
* testsuite/ld-elf/sec-to-seg.exp: Likewise.
* testsuite/ld-elf/tls_common.exp: Likewise.
* testsuite/ld-elfcomm/elfcomm.exp: Likewise.
* testsuite/ld-fastcall/fastcall.exp: Likewise.
* testsuite/ld-gc/gc.exp: Likewise.
* testsuite/ld-ifunc/binutils.exp: Likewise.
* testsuite/ld-mep/mep.exp: Likewise.
* testsuite/ld-mips-elf/mips-elf-flags.exp: Likewise.
* testsuite/ld-mn10300/mn10300.exp: Likewise.
* testsuite/ld-nios2/nios2.exp: Likewise.
* testsuite/ld-pe/pe-compile.exp: Likewise.
* testsuite/ld-pe/pe-run.exp: Likewise.
* testsuite/ld-pe/pe-run2.exp: Likewise.
* testsuite/ld-plugin/plugin.exp: Likewise.
* testsuite/ld-scripts/align.exp: Likewise.
* testsuite/ld-scripts/alignof.exp: Likewise.
* testsuite/ld-scripts/assert.exp: Likewise.
* testsuite/ld-scripts/defined.exp: Likewise.
* testsuite/ld-scripts/extern.exp: Likewise.
* testsuite/ld-scripts/log2.exp: Likewise.
* testsuite/ld-scripts/map-address.exp: Likewise.
* testsuite/ld-scripts/phdrs.exp: Likewise.
* testsuite/ld-scripts/phdrs2.exp: Likewise.
* testsuite/ld-scripts/script.exp: Likewise.
* testsuite/ld-scripts/section-flags.exp: Likewise.
* testsuite/ld-scripts/sizeof.exp: Likewise.
* testsuite/ld-scripts/sysroot-prefix.exp: Likewise.
* testsuite/ld-scripts/weak.exp: Likewise.
* testsuite/ld-selective/selective.exp: Likewise.
* testsuite/ld-sh/sh.exp: Likewise.
* testsuite/ld-sh/sh64/relax.exp: Likewise.
* testsuite/ld-sh/sh64/relfail.exp: Likewise.
* testsuite/ld-srec/srec.exp: Likewise.
* testsuite/ld-tic6x/tic6x.exp: Likewise.
* testsuite/ld-undefined/weak-undef.exp: Likewise.
* testsuite/ld-versados/versados.exp: Likewise.
* testsuite/ld-x86-64/dwarfreloc.exp: Likewise.
* testsuite/ld-xtensa/coalesce.exp: Likewise.
* testsuite/ld-xtensa/diff_overflow.exp: Likewise.
* testsuite/ld-xtensa/lcall.exp: Likewise.
* testsuite/ld-elf/audit.exp: Run non-native too.
* testsuite/ld-elf/compress.exp: Likewise. Replace ld options with
gcc -Wl, options.
* testsuite/ld-elf/dwarf.exp: Run non-native too. Use ld_link,
not ld_simple_link. Add -Wl,--no-as-needed to some tests.
* testsuite/ld-elf/elf.exp: Run non-native too. Formatting.
* testsuite/ld-elf/indirect.exp: Run non-native too. Add
-Wl,--no-as-needed to most tests.
* testsuite/ld-elf/shared.exp: Run non-native too. Use braces
to simplify quoting. Set run_tests using [list] rather than
brace assignment to expand $extralibs. Add -Wl,--no-as-needed
to many test. Prefix ld options with -Wl,.
(mix_pic_and_non_pic): Don't run exe if not native.
* testsuite/ld-elf/wrap.exp: Run non-native too. Add
-Wl,--no-as-needed and prefix ld options with -Wl,.
* testsuite/ld-elfvers/vers.exp: Run non-native too. Use ld_link,
not ld_simple_link.
* testsuite/ld-elfvsb/elfvsb.exp: Likewise.
(visibility_test): Don't run exe if not native.
* testsuite/ld-elfweak/elfweak.exp: Run non-native too. Use ld_link,
not ld_simple_link.
(build_exec): Don't run exe if not native.
* testsuite/ld-ifunc/ifunc.exp: Run non-native too. Use ld_link,
not ld_simple_link. Link using $CC. Add -Wl,--no-as-needed
to some tests and prefix ld options with -Wl,. Expect GNU
for hppa-linux even when no ifuncs. Delete cleanup.
* testsuite/ld-pie/pie.exp: Run non-native too.
* testsuite/ld-plugin/lto.exp: Likewise.
* testsuite/ld-shared/shared.exp: Likewise. Use ld_link,
not ld_simple_link.
(shared_test): Don't run exe if not native.
* testsuite/ld-size/size.exp: Run non-native too. Add
-Wl,--no-as-needed to some tests. Prefix ld options with -Wl,.
* testsuite/ld-unique/unique.exp: Run non-native too. Use ld_link,
not ld_simple_link. Link using $CC. Add -Wl,--no-as-needed
to some tests and prefix ld options with -Wl,. Expect GNU
for hppa-linux even when no unique syms. Delete cleanup.
* testsuite/ld-x86-64/tls.exp: Add -Wl,--no-as-needed to some
tests and prefix ld options with -Wl,.
* testsuite/ld-x86-64/x86-64.exp: Use ld_link, not ld_simple_link.
Add -Wl,--no-as-needed to some tests. Prefix ld options with -Wl,.
We don't want to report a test failure as a tcl error.
* testsuite/ld-scripts/sysroot-prefix.exp (sysroot_prefix_test_setup):
Call perror rather than error on "as" or "ar" failures.
gas/
* doc/c-lm32.texi: Fix chars with high bit set.
* testsuite/gas/bfin/vector2.s: Likewise.
gold/
* arm.cc: Fix comment chars with high bit set.
include/
* coff/pe.h: Fix comment chars with high bit set.
* opcode/xgate.h: Likewise.
ld/
* testsuite/ld-scripts/sysroot-prefix.exp: Fix chars with high bit set.
RX does horrible fudges to PT_LOAD p_vaddr, that affect the testsuite
and mean the target won't support dynamic objects. The latter
probably doesn't matter too much since RX is an embedded target, but
it's easy to stop some of the fudges in order to reduce special cases
for RX in the testsuite. The changes make sense in isolation too.
bfd/
* elf32-rx.c (elf32_rx_modify_program_headers): Don't adjust
segments that include the ELF file header or program headers.
ld/
* testsuite/ld-elf/flags1.d: Run for RX.
* testsuite/ld-scripts/phdrs.exp: Likewise.
* testsuite/ld-scripts/pr14962.d: Likewise.
* testsuite/ld-scripts/pr14962-2.d: Likewise.
PR ld/20815
bfd * elf.c (elf_modify_segment_map): Allow empty LOAD segments if
they contain the program headers.
(_bfd_elf_map_sections_to_segments): If the linker created the
PHDR segment then always attempt to include it in a LOAD segment.
(assign_file_positions_for_non_load_sections): Allow LOAD segments
to overlap PHDR segments.
(phdr_sorter): New function. Sorts program headers.
(assign_file_positions_except_relocs): Sort the program headers
before writing them out. Issue an error if the PHDR segment is
not covered by a LOAD segment, unless the backend allows it.
* elf-bfd.h (struct elf_backend_data): Add
elf_backend_allow_non_load_phdr.
* elfxx-target.h (elf_backend_allow_non_load_phdr): Provide
default definition that returns FALSE.
(elfNN_bed): Initialise the elf_backend_allow_non_load_phdr
field.
* elf64-hppa.c (elf64_hppa_allow_non_load_phdr): New function.
Returns TRUE.
(elf_backend_allow_non_load_phdr): Define.
* elf-m10300.c (_bfd_mn10300_elf_size_dynamic_sections): Do not
place the interpreter string into the .interp section if the
nointerp flag is set in the link info structure.
* elf32-arc.c (elf_arc_size_dynamic_sections): Likewise.
* elf32-score7.c (score_elf_final_link_relocate): Allow for the
_gp symbol not being part of the output.
binutils* readelf.c (process_program_headers): Check PT_LOAD and PT_PHDR
segments for validity.
ld * ld.texinfo: Note that PT_TLS can be used as a segment type.
* testsuite/ld-discard/discard.ld: Add space for program headers.
* testsuite/ld-elf/flags1.ld: Likewise.
* testsuite/ld-elf/maxpage3.t: Likewise.
* testsuite/ld-elf/noload-1.t: Likewise.
* testsuite/ld-elf/orphan.ld: Likewise.
* testsuite/ld-elf/overlay.t: Likewise.
* testsuite/ld-elf/pr14052.t: Likewise.
* testsuite/ld-elf/pr19539.t: Likewise.
* testsuite/ld-elf/provide-hidden-1.ld: Likewise.
* testsuite/ld-elf/provide-hidden-s.ld: Likewise.
* testsuite/ld-elf/weak-dyn-1.ld: Likewise.
* testsuite/ld-i386/pr19539.t: Likewise.
* testsuite/ld-scripts/defined.t: Likewise.
* testsuite/ld-scripts/defined6.t: Likewise.
* testsuite/ld-scripts/dynamic-sections.t: Likewise.
* testsuite/ld-scripts/empty-aligned.t: Likewise.
* testsuite/ld-scripts/provide-2.t: Likewise.
* testsuite/ld-scripts/provide-4.t: Likewise.
* testsuite/ld-vax-elf/plt-local.ld: Likewise.
* testsuite/ld-x86-64/pr19539.t: Likewise.
* testsuite/ld-elf/ehdr_start-missing.d: Do not initialise the
dynamic linker.
* testsuite/ld-elf/ehdr_start-weak.d: Likewise.
* testsuite/ld-elf/elf.exp (pr14170, pr17068): Likewise.
* testsuite/ld-elf/loadaddr1.d: Update expected readelf output.
* testsuite/ld-elf/noload-2.d: Likewise.
* testsuite/ld-powerpc/vxworks2.sd: Likewise.
* testsuite/ld-scripts/phdrs3a.d: Likewise.
* testsuite/ld-scripts/size-2.d: Likewise.
* testsuite/ld-elf/group.ld: Add program headers.
* testsuite/ld-elf/overlay.d: Skip for SPU.
* testsuite/ld-elf/flags1.d: Skip for RX.
* testsuite/ld-elf/pr19162.d: Skip for HPPA64.
* testsuite/ld-elf/pr19539.d: Skip for ALPHA.
* testsuite/ld-scripts/empty-orphan.t: Update program headers.
* testsuite/ld-scripts/size-2.t: Likewise.
Currently the EXCLUDE_FILE linker script construct can only be used
within the input section list, and applied only to the section pattern
immediately following the EXCLUDE_FILE. For example:
*.o (EXCLUDE_FILE (a.o) .text .rodata)
In this case all sections matching '.text' are included from all files
matching '*.o' but not from the file 'a.o'. All sections matching
'.rodata' are also included from all files matching '*.o' (incluing from
'a.o').
If the user wants to restrict the inclusion of section '.rodata' so that
this too is not taken from the file 'a.o' then the above example must be
extended like this:
*.o (EXCLUDE_FILE (a.o) .text EXCLUDE_FILE (a.o) .rodata)
However, due to the internal grammar of the linker script language the
snippet 'EXCLUDE_FILE (a.o) .text' is parsed by a pattern called
'wildcard_spec'. The same 'wildcard_spec' pattern is also used to parse
the input file name snippet '*.o' in the above examples. As a result of
this pattern reuse within the linker script grammar then the following
is also a valid linker script construct:
EXCLUDE_FILE (a.o) *.o (.text .rodata)
However, though the linker accepts this without complaint the
EXCLUDE_FILE part is silently ignored and has no effect.
This commit takes this last example and makes it a useful, valid,
construct. The last example now means to include sections '.text' and
'.rodata' from all files matching '*.o' except for the file 'a.o'.
If the list of input sections is long, and the user knows that the file
exclusion applies across the list then the second form might be a
clearer alternative to replicating the EXCLUDE_FILE construct.
I've added a set of tests for EXCLUDE_FILE to the linker, including
tests for the new functionality.
ld/ChangeLog:
* ldlang.h (struct lang_wild_statement_struct): Add
exclude_name_list field.
* ldlang.c (walk_wild_file_in_exclude_list): New function.
(walk_wild_consider_section): Use new
walk_wild_file_in_exclude_list function.
(walk_wild_file): Add call to walk_wild_file_in_exclude_list.
(print_wild_statement): Print new exclude_name_list field.
(lang_add_wild): Initialise new exclude_name_list field.
* testsuite/ld-scripts/exclude-file-1.d: New file.
* testsuite/ld-scripts/exclude-file-1.map: New file.
* testsuite/ld-scripts/exclude-file-1.t: New file.
* testsuite/ld-scripts/exclude-file-2.d: New file.
* testsuite/ld-scripts/exclude-file-2.map: New file.
* testsuite/ld-scripts/exclude-file-2.t: New file.
* testsuite/ld-scripts/exclude-file-3.d: New file.
* testsuite/ld-scripts/exclude-file-3.map: New file.
* testsuite/ld-scripts/exclude-file-3.t: New file.
* testsuite/ld-scripts/exclude-file-4.d: New file.
* testsuite/ld-scripts/exclude-file-4.map: New file.
* testsuite/ld-scripts/exclude-file-4.t: New file.
* testsuite/ld-scripts/exclude-file-a.s: New file.
* testsuite/ld-scripts/exclude-file-b.s: New file.
* testsuite/ld-scripts/exclude-file.exp: New file.
* ld.texinfo (Input Section Basics): Update description of
EXCLUDE_FILE to cover the new features.
* NEWS: Mention new EXCLUDE_FILE usage.
ld * testsuite/ld-elf/merge.d: Add m68hc11 to list of targets that
expect to fail this test.
* testsuite/ld-scripts/overlay-size.d: Skip the entire test for
RX.
* testsuite/ld-scripts/rgn-at10.d: No longer expect this test to
fail for the RX.
* testsuite/ld-scripts/rgn-at11.d: Likewise.
* testsuite/ld-scripts/rgn-at2.d: Likewise.
* testsuite/ld-scripts/rgn-at6.d: Likewise.
* testsuite/ld-scripts/rgn-at7.d: Likewise.
* testsuite/ld-scripts/rgn-at8.d: Likewise.
PR ld/20302
* lexsup.c (set_segment_start): If resetting the start address of
a section, remember to generate a new script element as well.
* testsuite/ld-scripts/pr20302.d: New test.
* testsuite/ld-scripts/scripts.exp: Run the new test.
A different set of hacks to make the crossref tests pass on powerpc64
and powerpc64le.
* testsuite/ld-scripts/crossref.exp: Remove -mcall-aixdesc hack.
* testsuite/ld-scripts/cross2.t: Tweak .opd and .toc placement.
* testsuite/ld-scripts/cross3.t: Likewise.
* testsuite/ld-scripts/cross4.t: Likewise.
* testsuite/ld-scripts/cross5.t: Likewise.
* testsuite/ld-scripts/cross6.t: Likewise.
* testsuite/ld-scripts/cross7.t: Likewise.
We don't want this to match .rela.text or similar.
* testsuite/ld-scripts/pr14962-2.t: Match .text, not *.text.
* testsuite/ld-scripts/rgn-at5.t: Similarly, .sec not *.sec.
* testsuite/ld-scripts/section-match-1.t: Likewise.
Fixes failures on hppa-linux and alpha-linux due to not merging
.data.* and .sdata into .data. cross3.t modified too since it is the
template for the NOCROSSREFS_TO scripts.
* testsuite/ld-scripts/cross3.t: Add commonly used data
and text section names to output section statements.
* testsuite/ld-scripts/cross4.t: Likewise.
* testsuite/ld-scripts/cross5.t: Likewise.
* testsuite/ld-scripts/cross6.t: Likewise.
* testsuite/ld-scripts/cross7.t: Likewise.
NOCROSSREFS_TO is similar to the existing NOCROSSREFS command but only
checks one direction of cross referencing.
ld/ChangeLog
* ld.texinfo: Document NOCROSSREFS_TO script command.
* ldlang.h (struct lang_nocrossrefs): Add onlyfirst field.
(lang_add_nocrossref_to): New prototype.
* ldcref.c (check_local_sym_xref): Use onlyfirst to only look for
symbols defined in the first section.
(check_nocrossref): Likewise.
* ldgram.y (NOCROSSREFS_TO): New script command.
* ldlang.c (lang_add_nocrossref): Set onlyfirst to FALSE.
(lang_add_nocrossref_to): New function.
* ldlex.l (NOCROSSREFS_TO): New token.
* NEWS: Mention NOCROSSREFS_TO.
* testsuite/ld-scripts/cross4.t: New file.
* testsuite/ld-scripts/cross5.t: Likewise.
* testsuite/ld-scripts/cross6.t: Likewise.
* testsuite/ld-scripts/cross7.t: Likewise.
* testsuite/ld-scripts/crossref.exp: Run 4 new NOCROSSREFS_TO
tests.
PR 18452
* ldlang.c (maybe_overlays): New static var.
(lang_size_sections_1): Set it here.
(struct check_sec): New.
(sort_sections_by_lma): Adjust for array of structs.
(sort_sections_by_vma): New function.
(lang_check_section_addresses): Check both LMA and VMA for overlap.
* testsuite/ld-scripts/rgn-over7.d: Adjust.
PR 19457
* testsuite/ld-scripts/script.exp (extract_symbol_test): Stop test
early for PE based targets.
* testsuite/ld-scripts/align.t: Use 0x1000 as VMA alignment.
* testsuite/ld-pe/tlssec32.d: Allow for relocatable output.
* testsuite/ld-scripts/rgn-at11.s: New file - based on rgn-at10.s
but with 16 byte section alignment.
* testsuite/ld-scripts/rgn-at11.d: Use new source file. Reenable
test for MIPS targets.
Run the test for more than just ELF. Shows that objcopy --extract-symbol
isn't working on PE, mips, mmix and some aout targets.
* config/default.exp (size): New global.
* ld-elf/extract-symbol-1.s,
* ld-elf/extract-symbol-1.ld,
* ld-elf/extract-symbol-1sec.d,
* ld-elf/extract-symbol-1sym.d: Delete.
* ld-scripts/script.exp (extract_symbol_test): New.
Giving linker script symbols defined outside of output sections a
section-relative value early, leads to them being used in expressions
as if they were defined inside an output section. This can mean loss
of the section VMA, and wrong results.
ld/
PR ld/18963
* ldexp.h (struct ldexp_control): Add rel_from_abs.
(ldexp_finalize_syms): Declare.
* ldexp.c (new_rel_from_abs): Keep absolute for expressions
outside of output section statements. Set rel_from_abs.
(make_abs, exp_fold_tree, exp_fold_tree_no_dot): Clear rel_from_abs.
(struct definedness_hash_entry): Add final_sec, and comment.
(update_definedness): Set final_sec.
(set_sym_sections, ldexp_finalize_syms): New functions.
* ldlang.c (lang_process): Call ldexp_finalize_syms.
ld/testsuite
PR ld/18963
* ld-scripts/pr18963.d,
* ld-scripts/pr18963.t: New test.
* ld-scripts/expr.exp: Run it.
* ld-elf/provide-hidden-2.ld: Explicitly make "dot" absolute.
* ld-mips-elf/gp-hidden.sd: Don't care about _gp section.
* ld-mips-elf/no-shared-1-n32.d: Don't care about symbol shown at
start of .data section.
* ld-mips-elf/no-shared-1-n64.d: Likewise.
* ld-mips-elf/no-shared-1-o32.d: Likewise.
NOCROSSREFS tests don't work with -fno-plt. This path appends
$PLT_CFLAGS to CC for NOCROSSREFS tests.
* ld-scripts/crossref.exp (CC): Save and restore. Append
$PLT_CFLAGS.
This patch fixes PR 4643 by allowing symbols in the LENGTH and ORIGIN
fields of MEMORY regions. Previously, only constants and constant
expressions are allowed.
For the AVR target, this helps define memory constraints more
accurately (per device), without having to create a ton of device
specific linker scripts.
ld/
PR 4643
* ldexp.c (fold_name): Fold LENGTH only after
lang_first_phase_enum.
* ldgram.y (memory_spec): Don't evaluate ORIGIN and LENGTH
rightaway.
* ldlang.h (struct memory_region_struct): Add origin_exp and
length_exp fields.
* ldlang.c (lang_do_memory_regions): New.
(lang_memory_region_lookup): Initialize origin_exp and
length_exp fields.
(lang_process): Call lang_do_memory_regions.
ld/testsuite/
* ld-scripts/memory.t: Define new symbol tred.
* ld-scripts/memory_sym.t: New.
* ld-scripts/script.exp: Perform MEMORY with symbols test, and
conditionally check values of linker symbols.
Tests that I added in commit c05b575a8d
fails on 32-bit hosts due to differences in whitespace.
This patch updates the expected output patterns to be more accepting of
differences in whitespace, the tests should now pass.
ld/testsuite/ChangeLog:
* ld-scripts/provide-4-map.d: Update expected output.
* ld-scripts/provide-5-map.d: Likewise.
When creating a linker mapfile (using -Map=MAPFILE), we previously would
always try to evaluate the expression from a PROVIDE statement.
However, this is not always safe, consider:
PROVIDE (foo = 0x10);
PROVIDE (bar = foo);
In this example, if neither 'foo' or 'bar' is needed, then while
generating the linker mapfile evaluating the expression for 'foo' is
harmless (just the value 0x10). However, evaluating the expression for
'bar' requires the symbol 'foo', which is undefined. This used to cause
a fatal error.
This patch changes the behaviour, so that when the destination of the
PROVIDE is not defined (that is the PROVIDE is not going to provide
anything) the expression is not evaluated, and instead a special string
is displayed to indicate that the linker is discarding the PROVIDE
statement.
This change not only fixes the spurious undefined symbol error, but also
means that a user can now tell if a PROVIDE statement has provided
anything by inspecting the linker mapfile, something that could not be
done before.
ld/ChangeLog:
* ldlang.c (print_assignment): Only evaluate the expression for a
PROVIDE'd assignment when the destination is being defined.
Display a special message for PROVIDE'd symbols that are not being
provided.
ld/testsuite/ChangeLog:
* ld-scripts/provide-4.d: New file.
* ld-scripts/provide-4-map.d: New file.
* ld-scripts/provide-4.t: New file.
* ld-scripts/provide-5.d: New file.
* ld-scripts/provide-5.s: New file.
* ld-scripts/provide-5-map.d: New file.
* ld-scripts/provide-5.t: New file.
* ld-scripts/provide.exp: Run the provide-4.d and provide-5.d
tests.
Add a new option 'map' to the ld run_dump_test mechanism. When the
'map' option is given run_dump_test will ensure that there is a
-Map=MAPFILE present in the linker command line, adding one if needed.
The MAPFILE is then compared with the file passed to the new 'map'
option using the regexp_diff function. This should make it slightly
easier to write tests that check the linker mapfile output.
The only test I found that already compares mapfile content is updated
to use the new mechanism.
ld/testsuite/ChangeLog:
* ld-scripts/overlay-size.d: Add 'map' option.
* ld-scripts/overlay-size.exp: Remove manual check of mapfile.
* lib/ld-lib.exp (run_dump_test): Add support for new 'map'
option, checking linker mapfile output.
* ld-scripts/sysroot-prefix.exp: Log $ld_sysroot. Handle sysroot
== "/" as a separate sysroot-configuration with separable
test-types.
(sysroot_prefix_tests): Include all existing sysroot tests in
sysroot == "/" tests except exclude those where a --sysroot option
is not specified.
* lib/ld-lib.exp (check_sysroot_available): Rewrite to use
--print-sysroot instead of relying on error code from using
--sysroot=... Also, set $ld_sysroot.
The reason we exclude not just the failing "full-path =-prefixed
without" but also the passing "plain =-prefixed without but -Lpath"
for sysroot == "/" is that for the latter to succeed, we have to make
assumptions about the system not having a /sysroot directory or
assumptions about its contents etc.
When passing --enable-targets=all --enable-64-bit-bfd (the
latter not required for a "64-bit-host" of course) the ld --help
output got too much to handle for poor tcl (or maybe dejagnu is
to blame) and remote_exec exited with an error, so the
configuration being tested was mishandled as being a
sysroot-less configuration. Using --version instead of --help
would work too, but the new --print-sysroot option calls for
nominal coverage, so why not use that instead.
* ld-scripts/sysroot-prefix.exp, ld-scripts/sysroot-prefix-x.s,
ld-scripts/sysroot-prefix-y.s: New files.
N.B: full coverage is only possible with complementary use of
--with-sysroot when configuring.
When aligning input sections, we are supposed to take the fill pattern
from a FILL statement, if there is one in the output section statement.
ld/
* ldlang.c (lang_size_sections_1 <lang_input_section_enum>): Use
current "fill", not "output_section_statement->fill".
ld/testsuite/
* ld-scripts/fill.d, * ld-scripts/fill.t, * ld-scripts/fill_0.s,
* ld-scripts/fill_1.s, * ld-scripts/fill_2.s: New test.
* ld-scripts/data.exp: Run it.
An assignment to dot in an output section that allocates space of
course keeps the output section. Here, I'm changing the behaviour for
assignments that don't allocate space. The idea is not so much to
allow people to force output of an empty section with ". = .", but
to fix cases where an otherwise empty section has padding added by an
alignment expression that changes with relaxation or .eh_frame
editing. Such a section might have zero size before relaxation and so
be stripped incorrectly.
ld/
* ld.texinfo (Output Section Discarding): Mention assigning to dot
as a way of keeping otherwise empty sections.
* ldexp.c (is_dot, is_value, is_sym_value, is_dot_ne_0,
is_dot_plus_0, is_align_conditional): New predicates.
(exp_fold_tree_1): Set SEC_KEEP when assigning to dot inside an
output section, except for some special cases.
* scripttempl/elfmicroblaze.sc: Use canonical form to align at
end of .heap and .stack.
ld/testsuite/
* ld-shared/elf-offset.ld: Align end of .bss with canonical form
of ALIGN that allows an empty .bss to be removed.
* ld-arm/arm-dyn.ld: Likewise.
* ld-arm/arm-lib.ld: Likewise.
* ld-elfvsb/elf-offset.ld: Likewise.
* ld-mips-elf/mips-dyn.ld: Likewise.
* ld-mips-elf/mips-lib.ld: Likewise.
* ld-arm/arm-no-rel-plt.ld: Remove duplicate ALIGN.
* ld-powerpc/vle-multiseg-1.ld: Remove ALIGN at start of section.
ALIGN address of section instead.
* ld-powerpc/vle-multiseg-2.ld: Likewise.
* ld-powerpc/vle-multiseg-3.ld: Likewise.
* ld-powerpc/vle-multiseg-4.ld: Likewise.
* ld-powerpc/vle-multiseg-6.ld: Likewise.
* ld-scripts/empty-aligned.d: Check section headers not program
headers. Remove xfail and notarget.
* ld-scripts/empty-aligned.t: Use canonical ALIGN for end of .text2.
Modifies ld machinery tracking linker script assignments to notice all
assignments, not just those symbols mentioned in DEFINED().
ld/
PR ld/14962
* ldlang.h (struct lang_definedness_hash_entry): Add by_object and
by_script. Make iteration a single bit field.
(lang_track_definedness, lang_symbol_definition_iteration): Delete.
(lang_symbol_defined): Declare.
* ldlang.c (lang_statement_iteration): Expand comment a little.
(lang_init <lang_definedness_table>): Make it bigger.
(lang_track_definedness, lang_symbol_definition): Delete.
(lang_definedness_newfunc): Update.
(lang_symbol_defined): New function.
(lang_update_definedness): Create entries here. Do track whether
script definition of symbol is valid, even when also defined in
an object file.
* ldexp.c (fold_name <DEFINED>): Update.
(fold_name <NAME>): Allow self-assignment for absolute symbols
defined in a linker script.
ld/testsuite/
* ld-scripts/pr14962-2.d,
* ld-scripts/pr14962-2.t: New test.
* ld-scripts/expr.exp: Run it.