Age | Commit message (Collapse) | Author | Files | Lines |
|
Fixes loongarch32-elf +FAIL: medium jirl plt
* testsuite/ld-loongarch-elf/cmodel.exp: Don't run test when
no shared library support.
|
|
cross compiling too
On Windows, filename_cmp is case insensitive, but when cross compiling
with libraries that may contain members with uppercase file names, we
should keep those comparisons case insensitive when running the build
tools on other OSes too.
Also make the check for .def consistent with the other ones, fixing
out of bounds reads if file names are shorter than 4 characters.
|
|
Fix the bug that can not generate func@plt
when linking a undefined function with cmodel=medium.
Add testcase.
bfd/
* elfnn-loongarch.c
ld/testsuite/ld-loongarch-elf/
* cmodel-libjirl.dd
* cmodel.exp
* libjirl.s
|
|
Fixes this when cross-compiling from x86_64-linux
x86_64-w64-mingw32 +FAIL: compiling shared lib fastcall/stdcall
* testsuite/ld-pe/pe-run2-def.exp (test_direct2_link_dll_def):
Use CC_FOR_TARGET and CFLAGS_FOR_TARGET rather than CC and CFLAGS.
|
|
PR 28362
* testsuite/ld-pe/pe-run2-def.exp: New file.
|
|
This changes readelf output a little, removing the 0x prefix on hex
output when the value is 0, except in cases where a fixed field
width is shown. %#010x is not a good replacement for 0x%08x.
|
|
ld/ChangeLog:
* NEWS: Fix 2 typos.
|
|
BFD_VMA_FMT can't be used in format strings that need to be
translated, because the translation won't work when the type of
bfd_vma differs from the machine used to compile .pot files. We've
known about this for a long time, but patches slip through review.
So just get rid of BFD_VMA_FMT, instead using the appropriate PRId64,
PRIu64, PRIx64 or PRIo64 and SCN variants for scanf. The patch is
mostly mechanical, the only thing requiring any thought is casts
needed to preserve PRId64 output from bfd_vma values, or to preserve
one of the unsigned output formats from bfd_signed_vma values.
|
|
Commit f493c2174e messed the formatting in linker map files,
particularly for 32-bit builds where a number of tests using map files
regressed. I should have noticed the BFD64 conditional printing of
spaces to line up output due to the original %V printing hex vmas with
16 digits when BFD64 and 8 digits when not. Besides that, it is nicer
to print 32-bit vmas for 32-bit targets. So change %V back to be
target dependent, now using bfd_sprintf_vma. Since minfo doesn't
return the number of chars printed, that means some places that
currently use %V must instead sprintf to a buffer in order to find the
length printed.
* ldmisc.h (print_spaces): Declare.
(print_space): Change to a macro.
* ldmisc.c (vfinfo): Use bfd_sprintf_vma for %V. Tidy %W case.
(print_space): Delete.
(print_spaces): New function.
* emultempl/aix.em (print_symbol): Use print_spaces.
* ldctor.c (ldctor_build_sets): Likewise.
* ldmain.c (add_archive_element): Likewise.
* ldlang.c (print_one_symbol, lang_print_asneeded): Likewise.
(print_output_section_statement, print_data_statement): Likewise.
(print_reloc_statement, print_padding_statement): Likewise.
(print_assignment): Likewise. Also replace %V printing of vmas
with printing to a buffer in order to properly format output.
(print_input_section, lang_one_common): Likewise.
|
|
Reset alignment for each PT_LOAD segment to avoid using alignment from
the previous PT_LOAD segment.
bfd/
PR ld/29435
* elf.c (assign_file_positions_for_load_sections): Reset
alignment for each PT_LOAD segment.
ld/
PR ld/29435
* testsuite/ld-elf/pr29435.d: New file.
* testsuite/ld-elf/pr29435.s: Likewise.
|
|
libraries and the BFD library's file caching mechanism.
PR 29389
bfd * bfd.c (BFD_CLOSED_BY_CACHE): New bfd flag.
* cache.c (bfd_cache_delete): Set BFD_CLOSED_BY_DELETE on the
closed bfd.
(bfd_cache_lookup_worker): Clear BFD_CLOSED_BY_DELETE on the newly
reopened bfd.
* opncls.c (bfd_set_filename): Refuse to change the name of a bfd
that has been closed by bfd_cache_delete. Mark changed bfds as
uncacheable.
* bfd-in2.h: Regenerate.
ld * ldlang.h (lang_input_statement_struct): Add sort_key field.
* emultempl/pe.em (after_open): If multiple import libraries refer
to the same bfd, store their names in the sort_key field.
* emultempl/pep.em (after_open): Likewise.
* ldlang.c (sort_filename): New function. Returns the filename to
be used when sorting input files.
(wild_sort): Use the sort_filename function.
|
|
In aarch64_tls_transition_without_check and elfNN_aarch64_tls_relax we
choose whether to perform a relaxation to an IE access model or an LE
access model based on whether the symbol itself is marked as local (i.e.
`h == NULL`).
This is problematic in two ways. The first is that sometimes a global
dynamic access can be relaxed to an initial exec access when creating a
shared library, and if that happens on a local symbol then we currently
relax it to a local exec access instead. This usually does not happen
since we only relax an access if aarch64_can_relax_tls returns true and
aarch64_can_relax_tls does not have the same problem. However, it can
happen when we have seen both an IE and GD access on the same symbol.
This case is exercised in the newly added testcase tls-relax-gd-ie-2.
The second problem is that deciding based on whether the symbol is local
misses the case when the symbol is global but is still non-interposable
and known to be located in the executable. This happens on all global
symbols in executables.
This case is exercised in the newly added testcase tls-relax-ie-le-4.
Here we adjust the condition we base our relaxation on so that we relax
to local-exec if we are creating an executable and the relevant symbol
we're accessing is stored inside that executable.
-- Updating tests for new relaxation criteria
Many of the tests added to check our relaxation to IE were implemented
by taking advantage of the fact that we did not relax a global symbol
defined in an executable.
Since a global symbol defined in an executable is still not
interposable, we know that a TLS version of such a symbol will be in the
main TLS block. This means that we can perform a stronger relaxation on
such symbols and relax their accesses to a local-exec access.
Hence we have to update all tests that relied on the older suboptimal
decision making.
The two cases when we still would want to relax a general dynamic access
to an initial exec one are:
1) When in a shared library and accessing a symbol which we have already
seen accessed with an initial exec access sequence.
2) When in an executable and accessing a symbol defined in a shared
library.
Both of these require shared library support, which means that these
tests are now only available on targets with that.
I have chosen to switch the existing testcases from a plain executable
to one dynamically linked to a shared object as that doesn't require
changing the testcases quite so much (just requires accessing a
different variable rather than requiring adding another code sequence).
The tls-relax-all testcase was an outlier to the above approach, since
it included a general dynamic access to both a local and global symbol
and inspected for the difference accordingly.
|
|
The updates are to ensure that the .data section exists. This means
that we always have a data section. That means that we don't create a
RWX segment and avoid the corresponding warning.
We get this warning when testing aarch64-none-elf with -mcmodel=tiny.
N.b. this changes quite a few testcases from fail to pass.
|
|
EXCLUDE_SYMBOLS keyword
This was requested in review.
|
|
directives
This maps to the same as ld's --exclude-symbols command line option,
but allowing specifying the option via directives embedded in the
object files instead of passed manually on the command line.
|
|
This syntactic sugar is present in both classical and emerging
architectures, like Alpha, SPARC and RISC-V, and assembler macros
doing the same thing can already be found in the wild e.g. [1], proving
the feature's popularity. It's better to provide support directly in the
assembler so downstream users wouldn't have to re-invent this over and
over again.
[1]: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/loongarch/sysdep.h;h=c586df819cd90;hb=HEAD#l28
|
|
b{lt/ge}[u] forms
Also re-order the jump/branch opcodes while at it, so that insns are
sorted in ascending order according to opcodes, and the label form
preceding the real definition.
|
|
These two macros print either a 16 digit hex number or an 8 digit
hex number. Unfortunately they depend on both target and host, which
means that the output for 32-bit targets may be either 8 or 16 hex
digits.
Replace them in most cases with code that prints a bfd_vma using
PRIx64. In some cases, deliberately lose the leading zeros.
This change some output, notably in base/offset fields of m68k
disassembly which I think looks better that way, and in error
messages. I've kept leading zeros in symbol dumps (objdump -t)
and in PE header dumps.
bfd/
* bfd-in.h (fprintf_vma, sprintf_vma, printf_vma): Delete.
* bfd-in2.h: Regenerate.
* bfd.c (bfd_sprintf_vma): Don't use sprintf_vma.
(bfd_fprintf_vma): Don't use fprintf_vma.
* coff-rs6000.c (xcoff_reloc_type_tls): Don't use sprintf_vma.
Instead use PRIx64 to print bfd_vma values.
(xcoff_ppc_relocate_section): Likewise.
* cofflink.c (_bfd_coff_write_global_sym): Likewise.
* mmo.c (mmo_write_symbols_and_terminator): Likewise.
* srec.c (srec_write_symbols): Likewise.
* elf32-xtensa.c (print_r_reloc): Similarly for fprintf_vma.
* pei-x86_64.c (pex64_dump_xdata): Likewise.
(pex64_bfd_print_pdata_section): Likewise.
* som.c (som_print_symbol): Likewise.
* ecoff.c (_bfd_ecoff_print_symbol): Use bfd_fprintf_vma.
opcodes/
* dis-buf.c (perror_memory, generic_print_address): Don't use
sprintf_vma. Instead use PRIx64 to print bfd_vma values.
* i386-dis.c (print_operand_value, print_displacement): Likewise.
* m68k-dis.c (print_base, print_indexed): Likewise.
* ns32k-dis.c (print_insn_arg): Likewise.
* ia64-gen.c (_opcode_int64_low, _opcode_int64_high): Delete.
(opcode_fprintf_vma): Delete.
(print_main_table): Use PRIx64 to print opcode.
binutils/
* od-macho.c: Replace all uses of printf_vma with bfd_printf_vma.
* objcopy.c (copy_object): Don't use sprintf_vma. Instead use
PRIx64 to print bfd_vma values.
(copy_main): Likewise.
* readelf.c (CHECK_ENTSIZE_VALUES): Likewise.
(dynamic_section_mips_val): Likewise.
(print_vma): Don't use printf_vma. Instead use PRIx64 to print
bfd_vma values.
(dump_ia64_vms_dynamic_fixups): Likewise.
(process_version_sections): Likewise.
* rddbg.c (stab_context): Likewise.
gas/
* config/tc-i386.c (offset_in_range): Don't use sprintf_vma.
Instead use PRIx64 to print bfd_vma values.
(md_assemble): Likewise.
* config/tc-mips.c (load_register, macro): Likewise.
* messages.c (as_internal_value_out_of_range): Likewise.
* read.c (emit_expr_with_reloc): Likewise.
* config/tc-ia64.c (note_register_values): Don't use fprintf_vma.
Instead use PRIx64 to print bfd_vma values.
(print_dependency): Likewise.
* listing.c (list_symbol_table): Use bfd_sprintf_vma.
* symbols.c (print_symbol_value_1): Use %p to print pointers.
(print_binary): Likewise.
(print_expr_1): Use PRIx64 to print bfd_vma values.
* write.c (print_fixup): Use %p to print pointers. Don't use
fprintf_vma.
* testsuite/gas/all/overflow.l: Update expected output.
* testsuite/gas/m68k/mcf-mov3q.d: Likewise.
* testsuite/gas/m68k/operands.d: Likewise.
* testsuite/gas/s12z/truncated.d: Likewise.
ld/
* deffilep.y (def_file_print): Don't use fprintf_vma. Instead
use PRIx64 to print bfd_vma values.
* emultempl/armelf.em (gld${EMULATION_NAME}_finish): Don't use
sprintf_vma. Instead use PRIx64 to print bfd_vma values.
* emultempl/pe.em (gld${EMULATION_NAME}_finish): Likewise.
* ldlang.c (lang_map): Use %V to print region origin.
(lang_one_common): Don't use sprintf_vma.
* ldmisc.c (vfinfo): Don't use fprintf_vma or sprintf_vma.
* pe-dll.c (pe_dll_generate_def_file): Likewise.
gdb/
* remote.c (remote_target::trace_set_readonly_regions): Replace
uses of sprintf_vma with bfd_sprintf_vma.
|
|
|
|
As discussed in PR ld/29411, the ld warning
[...] has a LOAD segment with RWX permissions
needs to be disabled on all SPARC targets, not just Solaris/SPARC: the
.plt section is required to be RWX by the 32-bit SPARC ELF psABI and the
64-bit SPARC Compliance Definition 2.4.1. Given that ld only supports
SPARC ELF targets, this patch implements this.
Tested on sparc64-unknown-linux-gnu and sparc-sun-solaris2.11.
2022-07-28 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
ld:
PR ld/29411
* configure.tgt (ac_default_ld_warn_rwx_segments): Extend to all
sparc targets. Expand comment.
|
|
PR 29411
* configure.tgt (ac_default_ld_warn_rwx_segments): Disable for
sparc-solaris configurations.
|
|
Three pppc32 ld tests fail when spe support is included in the linker
due to this snippet in ld/emulparams/elf32ppc.sh.
if grep -q 'ld_elf32_spu_emulation' ldemul-list.h; then
DATA_START_SYMBOLS="${RELOCATING+*crt1.o(.data .data.* .gnu.linkonce.d.*)
PROVIDE (__spe_handle = .);
*(.data.spehandle)
. += 4 * (DEFINED (__spe_handle) || . != 0);}"
fi
* testsuite/ld-powerpc/tlsexe32.r: Pass with .data section present.
* testsuite/ld-powerpc/tlsexe32no.r: Likewise.
* testsuite/ld-powerpc/tlsso32.r: Likewise.
|
|
|
|
When GCC 12 is used to build binutils with -O0, the following 2 tests
failed:
FAIL: Conflicted data syms, partially indexed, stripped, with variables
FAIL: Conflicted data syms, partially indexed, stripped
Compile 2 tests with -O2 to avoid test failures.
PR ld/29378
* testsuite/ld-ctf/data-func-conflicted-vars.d: Compile with -O2.
* testsuite/ld-ctf/data-func-conflicted.d: Likewise.
|
|
gas/testsuite/gas/all/
gas.exp
gas/testsuite/gas/loongarch/
jmp_op.d
jmp_op.s
macro_op.d
macro_op.s
macro_op_32.d
macro_op_32.s
macro_op_large_abs.d
macro_op_large_abs.s
macro_op_large_pc.d
macro_op_large_pc.s
reloc.d
reloc.s
ld/testsuite/ld-elf/
pr26936.d
shared.exp
ld/testsuite/ld-loongarch-elf/
attr-ifunc-4.c
attr-ifunc-4.out
disas-jirl.d
ifunc.exp
jmp_op.d
jmp_op.s
libnopic-global.s
macro_op.d
macro_op.s
macro_op_32.d
macro_op_32.s
nopic-global-so.rd
nopic-global-so.sd
nopic-global.out
nopic-global.s
nopic-global.sd
nopic-global.xd
nopic-local.out
nopic-local.rd
nopic-local.s
nopic-local.sd
nopic-local.xd
nopic-weak-global-so.rd
nopic-weak-global-so.sd
nopic-weak-global.out
nopic-weak-global.s
nopic-weak-global.sd
nopic-weak-global.xd
nopic-weak-local.out
nopic-weak-local.rd
nopic-weak-local.s
nopic-weak-local.sd
nopic-weak-local.xd
pic.exp
pic.ld
|
|
Some R_LARCH_64 in section .eh_frame will to generate
R_LARCH_NONE, we change relocation to R_LARCH_32_PCREL
from R_LARCH_64 in setction .eh_frame and not generate
dynamic relocation for R_LARCH_32_PCREL.
Add New relocate type R_LARCH_32_PCREL for .eh_frame.
include/elf/
loongarch.h
bfd/
bfd/bfd-in2.h
libbfd.h
reloc.c
elfxx-loongarch.c
elfnn-loongarch.c
gas/config/
tc-loongarch.c
binutils/
readelf.c
ld/testsuite/ld-elf/
eh5.d
|
|
On seeing PR29369 my suspicion was naturally on a recent powerpc64
change, commit 0ab80031430e. Without a reproducer, I spent time
wondering what could have gone wrong, and while I doubt this patch
would have fixed the PR, there are some improvements that can be made
to cater for user silliness.
I also noticed that when -z relro -z now sections are created out of
order, with .got before .plt in the section headers but .got is laid
out at a higher address. That's due to the address expression for
.branch_lt referencing SIZEOF(.got) and so calling init_os (which
creates a bfd section) for .got before the .plt section is created.
Fix that by ignoring SIZEOF in exp_init_os. Unlike ADDR and LOADADDR
which need to reference section vma and lma respectively, SIZEOF can
and does cope with a missing bfd section by returning zero for its
size, which of course is correct.
PR 29369
* ldlang.c (exp_init_os): Don't create a bfd section for SIZEOF.
* emulparams/elf64ppc.sh (OTHER_RELRO_SECTIONS_2): Revise
.branch_lt address to take into account possible user sections
with alignment larger than 8 bytes.
|
|
sbrk hasn't been used in binutils/ or ld/ for quite some time (so the
PR was fixed a while ago). Tidy up configury.
PR 17122
binutils/
* configure.ac: Don't check for sbrk.
* sysdep.h (sbrk): Don't supply fallback declaration.
* config.in: Regenerate.
* configure: Regenerate.
ld/
* configure.ac: Don't check for sbrk.
* config.in: Regenerate.
* configure: Regenerate.
|
|
We can't use the PLT entry as the function address for PIC since the PIC
register may not be set up properly for indirect call.
bfd/
PR ld/27998
* elf32-i386.c (elf_i386_relocate_section): Don't allow GOTOFF
relocation against IFUNC symbol for PIC.
ld/
PR ld/27998
* testsuite/ld-i386/pr27998a.d: Replace -shared with -e bar.
* testsuite/ld-i386/pr27998b.d: Expect a linker error.
* testsuite/ld-ifunc/ifunc-2-i386-now.d: Updated.
* testsuite/ld-ifunc/ifunc-2-local-i386-now.d: Likewise.
* testsuite/ld-ifunc/ifunc-2-i386.s: Replace @GOTOFF with @GOT.
* testsuite/ld-ifunc/ifunc-2-local-i386.s: Likewise.
|
|
Since glibc 2.36 will issue warnings for copy relocation against
protected symbols and non-canonical reference to canonical protected
functions, change the linker to always disallow such relocations.
bfd/
* elf32-i386.c (elf_i386_scan_relocs): Remove check for
elf_has_indirect_extern_access.
* elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.
(elf_x86_64_relocate_section): Remove check for
elf_has_no_copy_on_protected.
* elfxx-x86.c (elf_x86_allocate_dynrelocs): Check for building
executable instead of elf_has_no_copy_on_protected.
(_bfd_x86_elf_adjust_dynamic_symbol): Disallow copy relocation
against non-copyable protected symbol.
* elfxx-x86.h (SYMBOL_NO_COPYRELOC): Remove check for
elf_has_no_copy_on_protected.
ld/
* testsuite/ld-i386/i386.exp: Expect linker error for PR ld/17709
test.
* testsuite/ld-i386/pr17709.rd: Removed.
* testsuite/ld-i386/pr17709.err: New file.
* testsuite/ld-x86-64/pr17709.rd: Removed.
* testsuite/ld-x86-64/pr17709.err: New file.
* testsuite/ld-x86-64/pr28875-func.err: Updated.
* testsuite/ld-x86-64/x86-64.exp: Expect linker error for PR
ld/17709 test. Add tests for function pointer against protected
function.
|
|
Call _bfd_elf_symbol_refs_local_p with local_protected==true. This has
2 noticeable effects for -shared:
* GOT-generating relocations referencing a protected data symbol no
longer lead to a GLOB_DAT (similar to a hidden symbol).
* Direct access relocations (e.g. R_X86_64_PC32) no longer has the
confusing diagnostic below.
__attribute__((visibility("protected"))) void *foo() {
return (void *)foo;
}
// gcc -fpic -shared -fuse-ld=bfd
relocation R_X86_64_PC32 against protected symbol `foo' can not be used when making a shared object
The new behavior matches arm, aarch64 (commit
83c325007c5599fa9b60b8d5f7b84842160e1d1b), and powerpc ports, and other
linkers: gold and ld.lld.
Note: if some code tries to use direct access relocations to take the
address of foo, the pointer equality will break, but the error should be
reported on the executable link, not on the innocent shared object link.
glibc 2.36 will give a warning at relocation resolving time.
With this change, `#define elf_backend_extern_protected_data 1` is no
longer effective. Just remove it.
Remove the test "Run protected-func-1 without PIE" since -fno-pic
address taken operation in the executable doesn't work with protected
symbol in a shared object by default. Similarly, remove
protected-data-1a and protected-data-1b. protected-data-1b can be made
working by removing HAVE_LD_PIE_COPYRELOC from GCC
(https://sourceware.org/pipermail/gcc-patches/2022-June/596678.html).
|
|
Pass -nostdlib to compiler with -r to avoid unnecessary .o file and
libraries.
PR ld/29377
* testsuite/ld-elf/linux-x86.exp: Pass -nostdlib with -r.
|
|
Only check invalid relocation against protected symbol defined in shared
object.
bfd/
PR ld/29377
* elf32-i386.c (elf_i386_scan_relocs): Only check invalid
relocation against protected symbol defined in shared object.
* elf64-x86-64.c (elf_x86_64_scan_relocs): Likewise.
ld/
PR ld/29377
* testsuite/ld-elf/linux-x86.exp: Run PR ld/29377 tests.
* testsuite/ld-elf/pr29377a.c: New file.
* testsuite/ld-elf/pr29377b.c: Likewise.
|
|
|
|
|
|
|
|
commit d0e0f9c87a3e results "ERROR: i586-linux-cc does not exist" if
cross-building an i586-linux target without a target compiler
installed.
* testsuite/ld-elf/linux-x86.exp (compiler_honours_aligned): New.
Use it after first testing check_compiler_available.
|
|
When the compiler doesn't properly arrange for foo's alignment, there's
no point even trying these tests. Report the situation as a single
"unsupported" test.
|
|
plt_branch stubs are similar to plt_call stubs in that they branch
via bctr. Align them too.
bfd/
* elf64-ppc.c (ppc_size_one_stub): Align plt_branch stubs as for
plt_call stubs.
ld/
* testsuite/ld-powerpc/elfv2exe.d: Adjust for plt_branch changes.
* testsuite/ld-powerpc/notoc.d: Likewise.
* testsuite/ld-powerpc/notoc.wf: Likewise.
* testsuite/ld-powerpc/notoc3.d: Likewise.
* testsuite/ld-powerpc/pr23937.d: Likewise.
|
|
PR 29263
* configure.ac: Fix typo.
* testsuite/ld-elf/elf.exp: Add mips to targets that need
--warn-execstack to pass first pr29072 test.
|
|
PR 29263
* configure.ac: Move HPPA specific code from here...
* configure.tgt: ... to here. Add similar code for MIPS.
Move code for CRIS, MIPS and HPPA to block at start of file.
* configure: Regenerate.
|
|
Commit 04f096fb9e25 ("Move the xc16x target to the obsolete list") moved
the architecture from the "obsolete but still available" to the
"obsolete / support removed" list in config.bfd, making the architecture
impossible to enable (except maybe via "enable everything" options").
Note that I didn't touch */po/*.po{,t} on the assumption that these
would be updated by some (half)automatic means.
|
|
.branch_lt is really an extension of .plt, as is .iplt. We'd like all
of the PLT sections to be fixed relative to .TOC. after stub sizing,
because changes in offset to PLT entries might mean a change in stub
sizes. When -z relro, the relro layout does this by laying out
sections from the end of the relro segment. So for example, a change
in .eh_frame (which happens after stub sizing) will keep the same GOT
to PLT offset when -z relro. Not so when -z norelro, because then the
usual forward layout of section is done and .got is more aligned than
.branch_lt.
* emulparams/elf64ppc.sh: Set .branch_lt address fixed relative
to .got.
* testsuite/ld-powerpc/elfv2exe.d: Adjust to suit.
|
|
A number of targets use assignments like:
. = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 12 ? 12 : 0, .);
(from i386) in linker scripts to put the end of the relro segment past
the header in .got.plt. Examination of testcases like those edited by
this patch instead sees the end of the relro segment being placed at
the start of .got.plt. For the i386 pie1 test:
[ 9] .got.plt PROGBITS 00002000 001000 00000c 04 WA 0 0 4
GNU_RELRO 0x000f90 0x00001f90 0x00001f90 0x00070 0x00070 R 0x1
A map file shows:
.dynamic 0x0000000000001f90 0x70
*(.dynamic)
.dynamic 0x0000000000001f90 0x70 tmpdir/pie1.o
0x0000000000001f90 _DYNAMIC
.got 0x0000000000002000 0x0
*(.got)
.got 0x0000000000002000 0x0 tmpdir/pie1.o
*(.igot)
0x0000000000002ff4 . = DATA_SEGMENT_RELRO_END (., (SIZEOF (.got.plt) >= 0xc)?0xc:0x0)
.got.plt 0x0000000000002000 0xc
*(.got.plt)
.got.plt 0x0000000000002000 0xc tmpdir/pie1.o
0x0000000000002000 _GLOBAL_OFFSET_TABLE_
The DATA_SEGMENT_RELRO_END value in the map file is weird too. All of
this is triggered by SIZEOF (.got.plt) being evaluated wrongly as
zero. Fix it by taking into account the action of
lang_reset_memory_regions during relaxation.
* ldexp.c (fold_name <SIZEOF>): Use rawsize if size has been reset.
* ldlang.c (lang_size_sections_1): Don't reset processed_vma here.
* testsuite/ld-i386/pie1.d: Adjust to suit.
* testsuite/ld-x86-64/pr20830a.d: Likewise.
* testsuite/ld-x86-64/pr20830b.d: Likewise.
* testsuite/ld-x86-64/pr21038a.d: Likewise.
* testsuite/ld-x86-64/pr21038b.d: Likewise.
* testsuite/ld-x86-64/pr21038c.d: Likewise.
|
|
Similar to commit 4fb55bf6a9606eb7b626c30a9f4e71d6c2d4fbb2 for aarch64.
Commit b68a20d6675f1360ea4db50a9835c073675b9889 changed ld to produce
R_ARM_GLOB_DAT but that defeated the purpose of protected visibility
as an optimization. Restore the previous behavior (which matches
ld.lld) by defining elf_backend_extern_protected_data to 0.
|
|
__attribute__((visibility("protected"))) void *foo() {
return (void *)foo;
}
gcc -fpic -shared -fuse-ld=bfd fails with the confusing diagnostic:
relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `foo' which may bind externally can not be used when making a shared object; recompile with -fPIC
Call _bfd_elf_symbol_refs_local_p with local_protected==true to suppress
the error. The new behavior matches gold and ld.lld.
Note: if some code tries to use direct access relocations to take the
address of foo (likely due to -fno-pic), the pointer equality will
break, but the error should be reported on the executable link, not on
the innocent shared object link. glibc 2.36 will give a warning at
relocation resolving time.
|
|
Follow-up to commit 90b7a5df152a64d2bea20beb438e8b81049a5c30
("aarch64: Disallow copy relocations on protected data").
Commit 32f573bcb3aaa1c9defcad79dbb5851fcc02ae2d changed ld to produce
R_AARCH64_GLOB_DAT but that defeated the purpose of protected visibility
as an optimization. Restore the previous behavior (which matches
ld.lld) by defining elf_backend_extern_protected_data to 0.
|
|
If an executable has copy relocations for extern protected data, that
can only work if the shared object containing the definition is built
with assumptions (a) the compiler emits GOT-generating relocations (b)
the linker produces R_*_GLOB_DAT instead of R_*_RELATIVE. Otherwise the
shared object uses its own definition directly and the executable
accesses a stale copy. Note: the GOT relocations defeat the purpose of
protected visibility as an optimization, and it turns out this never
worked perfectly.
glibc 2.36 will warn on copy relocations on protected data. Let's
produce a warning at link time, matching ld.lld which has been used on
many aarch64 OSes.
Note: x86 requires GNU_PROPERTY_NO_COPY_ON_PROTECTED to have the error.
This is to largely due to GCC 5's "x86-64: Optimize access to globals in
PIE with copy reloc" which started to use direct access relocations for
external data symbols in -fpie mode.
GCC's aarch64 port does not have the change. Nowadays with most builds
switching to -fpie/-fpic, aarch64 mostly doesn't need to worry about
copy relocations. So for aarch64 we simply don't check
GNU_PROPERTY_NO_COPY_ON_PROTECTED.
|
|
Things work again after this.
ld/ChangeLog:
* configure: Regenerate.
|
|
the target is the HPPA architecture.
PR 29263
* configure.ac (ac_default_ld_warn_execstack): Default to 'no' for
HPPA targets.
(ac_default_ld_warn_rwx_segments): Likewise.
* configure: Regenerate.
* testsuite/ld-elf/elf.exp: Add the --warn-execstack command line
option to the command line when running execstack tests for the
HPPA target.
|