aboutsummaryrefslogtreecommitdiff
path: root/bfd/bfd.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-12-06 11:45:41 -0800
committerH.J. Lu <hjl.tools@gmail.com>2024-03-26 07:17:17 -0700
commitbb9a951fab7a30cc1209c6b8b1716c13456e8b1a (patch)
treec3defd5dc0641dbcd0872ea9b5a738bff9262a2d /bfd/bfd.c
parentf4c19f89ef43dbce8065532c808e1aeb05d08994 (diff)
downloadgdb-bb9a951fab7a30cc1209c6b8b1716c13456e8b1a.zip
gdb-bb9a951fab7a30cc1209c6b8b1716c13456e8b1a.tar.gz
gdb-bb9a951fab7a30cc1209c6b8b1716c13456e8b1a.tar.bz2
Don't claim a fat IR object if no IR object should be claimed
When the linker sees an input object containing nothing but IR during rescan, it should ignore it (LTO phase is over). But if the input object is a fat IR object, which has non-IR code as well, it should be used to resolve references as if it did not contain any IR at all. This patch adds lto_type to bfd and linker avoids claiming a fat IR object if no IR object should be claimed. bfd/ PR ld/23935 * archive.c (_bfd_compute_and_write_armap): Check bfd_get_lto_type instead of lto_slim_object. * elflink.c (elf_link_add_object_symbols): Likewise. * bfd.c (bfd_lto_object_type): New. (bfd): Remove lto_slim_object and add lto_type. (bfd_get_lto_type): New function. * elf.c (lto_section): Removed. (_bfd_elf_make_section_from_shdr): Don't set lto_slim_object. * format.c: (lto_section): New. (bfd_set_lto_type): New function. (bfd_check_format_matches): Call bfd_set_lto_type. * bfd-in2.h: Regenerated. binutils/ PR ld/23935 * nm.c (display_rel_file): Check bfd_get_lto_type instead of lto_slim_object. ld/ PR ld/23935 * ldmain.c (add_archive_element): Don't claim a fat IR object if no IR object should be claimed. * testsuite/ld-plugin/lto.exp (pr20103): Adjust fat IR test. Add PR ld/23935 test. * testsuite/ld-plugin/pr23935a.c: New file. * testsuite/ld-plugin/pr23935b.c: Likewise.
Diffstat (limited to 'bfd/bfd.c')
-rw-r--r--bfd/bfd.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 54061a3..e579788 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -74,6 +74,14 @@ EXTERNAL
. bfd_byte data[1];
. };
.
+.enum bfd_lto_object_type
+. {
+. lto_non_object, {* Not an LTO object. *}
+. lto_non_ir_object, {* An object without LTO IR. *}
+. lto_slim_ir_object, {* A slim LTO IR object. *}
+. lto_fat_ir_object {* A fat LTO IR object. *}
+. };
+.
CODE_FRAGMENT
.struct bfd
@@ -278,13 +286,13 @@ CODE_FRAGMENT
. {* Set if this is a plugin output file. *}
. unsigned int lto_output : 1;
.
-. {* Set if this is a slim LTO object not loaded with a compiler plugin. *}
-. unsigned int lto_slim_object : 1;
-.
. {* Do not attempt to modify this file. Set when detecting errors
. that BFD is not prepared to handle for objcopy/strip. *}
. unsigned int read_only : 1;
.
+. {* LTO object type. *}
+. ENUM_BITFIELD (bfd_lto_object_type) lto_type : 2;
+.
. {* Set to dummy BFD created when claimed by a compiler plug-in
. library. *}
. bfd *plugin_dummy_bfd;
@@ -428,6 +436,12 @@ EXTERNAL
. return abfd->format;
.}
.
+.static inline enum bfd_lto_object_type
+.bfd_get_lto_type (const bfd *abfd)
+.{
+. return abfd->lto_type;
+.}
+.
.static inline flagword
.bfd_get_file_flags (const bfd *abfd)
.{