[PATCH] ld: Add ehdr_start to bfd_link_hash_entry
H.J. Lu
hjl.tools@gmail.com
Sun Jan 2 03:37:19 GMT 2022
__ehdr_start is a special symbol which is undefined during link. It
becomes defined almost at the last minute if it is referenced. Add
ehdr_start to bfd_link_hash_entry for __ehdr_start so that ELF linker
can properly handle it.
include/
* bfdlink.h (bfd_link_hash_entry): Add ehdr_start.
ld/
* ldelf.c (ldelf_before_allocation): Set ehdr_start for
__ehdr_start.
---
include/bfdlink.h | 3 +++
ld/ldelf.c | 1 +
2 files changed, 4 insertions(+)
diff --git a/include/bfdlink.h b/include/bfdlink.h
index f3a52b04026..073baa64fb1 100644
--- a/include/bfdlink.h
+++ b/include/bfdlink.h
@@ -121,6 +121,9 @@ struct bfd_link_hash_entry
/* Symbol defined in a linker script. */
unsigned int ldscript_def : 1;
+ /* This the special ELF symbol: __ehdr_start. */
+ unsigned int ehdr_start : 1;
+
/* Symbol will be converted from absolute to section-relative. Set for
symbols defined by a script from "dot" (also SEGMENT_START or ORIGIN)
outside of an output section statement. */
diff --git a/ld/ldelf.c b/ld/ldelf.c
index 202c43a58ef..dc317be290a 100644
--- a/ld/ldelf.c
+++ b/ld/ldelf.c
@@ -1617,6 +1617,7 @@ ldelf_before_allocation (char *audit, char *depaudit,
ehdr_start->type = bfd_link_hash_defined;
/* It will be converted to section-relative later. */
ehdr_start->rel_from_abs = 1;
+ ehdr_start->ehdr_start = 1;
ehdr_start->u.def.section = bfd_abs_section_ptr;
ehdr_start->u.def.value = 0;
}
--
2.33.1
More information about the Binutils
mailing list