Undefined weak symbols with non-default visibility are seen as local
by SYMBOL_REFERENCES_LOCAL. This stops a got indirect to relative
optimisation for them, so that pies and dlls don't get non-zero values
when loading somewhere other than the address they are linked at
(which always happens). The optimisation could be allowed for pdes,
but I thought it best not to allow it there too.
bfd/
* elf64-ppc.c (ppc64_elf_relocate_section): Don't optimise got
indirect to pc-relative or toc-relative for undefined symbols.
ld/
* testsuite/ld-powerpc/weak1.d,
* testsuite/ld-powerpc/weak1.r,
* testsuite/ld-powerpc/weak1.s,
* testsuite/ld-powerpc/weak1so.d,
* testsuite/ld-powerpc/weak1so.r: New tests.
* testsuite/ld-powerpc/powerpc.exp: Run them.
(cherry picked from commit f5b9c288a3)
This makes IR objects use the same logic as normal objects with
respect to what sort of ref/def makes an as-needed library needed.
Testing the binding of the definition is just plain wrong. What
matters is the binding of the reference.
PR 27441
* elf-bfd.h (struct elf_link_hash_entry): Add ref_ir_nonweak.
* elflink.c (elf_link_add_object_symbols): Set ref_ir_nonweak and
use when deciding an as-needed library should be loaded instead
of using the binding of the library definition.
(cherry picked from commit bbaddd4bbe)
This patch makes use of the temp file descriptor in smart_rename
rather than reopening the file. I don't believe there is a security
issue in reopening the file, but this way is one less directory
operation. The patch also attempts to preserve S_ISUID and S_ISGID.
PR 27456
* bucomm.h (smart_rename): Update prototype.
* rename.c (smart_rename): Add fromfd and preserve_dates params.
Pass fromfd and target_stat to simple_copy. Call set_times
when preserve_dates.
(simple_copy): Accept fromfd rather than from filename. Add
target_stat param. Rewind fromfd rather than opening. Open
"to" file without O_CREAT. Try to preserve S_ISUID and S_ISGID.
* ar.c (write_archive): Rename ofd to tmpfd. Dup tmpfd before
closing output temp file, and pass tmpfd to smart_rename.
* arsup.c (temp_fd): Rename from real_fd.
(ar_save): Dup temp_fd and pass to smart_rename.
* objcopy.c (strip_main, copy_main): Likewise, and pass
preserve_dates.
(cherry picked from commit c42c71a152)
In the interests of a stable release various last minute smart_rename
patches were backed out of the 2.36 branch. The main reason to
reinstate some of those backed out changes here is to make necessary
followup fixes to commit 8e03235147 simple cherry-picks from
mainline. A secondary reason is that ar -M support isn't fixed for
pr26945 without this patch.
PR 26945
* ar.c: Don't include libbfd.h.
(write_archive): Replace xmalloc+strcpy with xstrdup.
* arsup.c (temp_name, real_ofd): New static variables.
(ar_open): Use make_tempname and bfd_fdopenw.
(ar_save): Adjust to suit ar_open changes.
* objcopy.c: Don't include libbfd.h.
* rename.c: Rename and reorder variables.
(cherry picked from commit 95b91a043a)
Renaming over existing files needs additional care to restore
permissions and ownership, which may not always succeed.
Additionally, other properties of the file such as extended attributes
may be lost, making the operation flaky.
For predictable results, resort to rename() only if the file does not
exist, otherwise copy the file contents into the existing file. This
ensures that no additional tricks are needed to retain file
properties.
This also allows dropping of the redundant set_times on the tmpfile in
objcopy/strip since now we no longer rename over existing files.
binutils/
* ar.c (write_archive): Adjust call to SMART_RENAME.
* arsup.c (ar_save): Likewise.
* objcopy (strip_main): Don't set times on temporary file and
adjust call to SMART_RENAME.
(copy_main): Likewise.
* rename.c [!S_ISLNK]: Remove definitions.
(try_preserve_permissions): Remove function.
(smart_rename): Replace PRESERVE_DATES argument with
TARGET_STAT. Use rename system call only if TO does not exist.
* bucomm.h (smart_rename): Adjust declaration.
(cherry picked from commit 3685de750e)
opcodes/
* s390-mkopc.c (main): Accept arch14 as cpu string.
* s390-opc.txt: Add new arch14 instructions.
include/
* opcode/s390.h (enum s390_opcode_cpu_val): Add
S390_OPCODE_ARCH14.
gas/
* config/tc-s390.c (s390_parse_cpu): New entry for arch14.
* doc/c-s390.texi: Document arch14 march option.
* testsuite/gas/s390/s390.exp: Run the arch14 related tests.
* testsuite/gas/s390/zarch-arch14.d: New test.
* testsuite/gas/s390/zarch-arch14.s: New test.
(cherry picked from commit ba2b480f10)
Remove x86 ISA level run-time tests since with glibc 2.33, they will fail
to run on machines with lesser x86 ISA level:
tmpdir/property-5-pie: CPU ISA level is lower than required
PR ld/27358
* testsuite/ld-i386/i386.exp: Remove property 3/4/5 run-time
tests.
* testsuite/ld-x86-64/x86-64.exp: Likewise.
(cherry picked from commit 38a143aa8c)
This reverts commit 014cc7f849.
Given the problems associated with this patch and the others intended to fix the smart_rename CVE, the decision has been taken to$
This reverts commit b143e2d506.
Given the problems associated with this patch and the others intended to fix the smart_rename CVE, the decision has been taken to$
This reverts commit 95b91a043a.
Given the problems associated with this patch and the others intended to fix the smart_rename CVE, the decision has been taken to$
This reverts commit c0034ac596.
Given the problems associated with this patch and the others intended to fix the smart_rename CVE, the decision has been taken to revert the patches for the 2.36.1 point release.
We can just use stat here, the same as is done in ar.c:open_inarch.
PR 27345
* arsup.c (ar_save): Use stat rather than lstat.
(cherry picked from commit c180f095f3)