]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Error linking binaries with differing e_flags.
authorMatthew Malcomson <matthew.malcomson@arm.com>
Mon, 7 Feb 2022 16:54:55 +0000 (16:54 +0000)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 1 Sep 2022 22:59:25 +0000 (15:59 -0700)
commit00ef0d31ac92f61336d4f9eceab342fd88ad7e5e
treeaed0e1568f9281205bbfe79aa19451051479b5bf
parent2478c950a85344a638a1e4d77454e29e362ae15f
Error linking binaries with differing e_flags.

This commit is partly changing two existing (believed buggy) behaviours
in elfNN_aarch64_merge_private_bfd_data and partly accounting for a
capability-specific requirement.

The existing behaviours in elfNN_aarch64_merge_private_bfd_data were:
1) It returned `TRUE` by default.  This effectively ignored the ELF
   flags on the binaries, despite there being code looking at them.
2) We do not mark the output BFD as initialised until we see flags with
   non-default architecture and flags.  This can't tell the difference
   between linking default objects to non-default objects if the default
   objects are given first on the command line.

The capability-specific requirement is:
- This function originally returned early if the object file getting
  merged into the existing output object file is not dynamic and has no
  code sections.  The code reasoned that differing ELF flags did not
  matter in this case since there was no code that would be expecting
  it.
  For capabilities the binary compatibility is still important.
  Data sections now contain capabilities as pointers, got sections now
  have a different got element size.
  Hence we avoid this short-circuit if any of the flags we're checking
  are the CHERI_PURECAP flag.
bfd/elfnn-aarch64.c
ld/testsuite/ld-aarch64/aarch64-elf.exp
ld/testsuite/ld-aarch64/morello-disallow-merged-binaries-code.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/morello-disallow-merged-binaries-data.s [new file with mode: 0644]
ld/testsuite/ld-aarch64/morello-disallow-merged-binaries.d [new file with mode: 0644]