1 Star 0 Fork 25

lixing.loongson.cn/binutils_anolis

forked from src-anolis-os/binutils 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
binutils-x86-local-relocs.patch 2.10 KB
一键复制 编辑 原始数据 按行查看 历史
张彬琛 提交于 2021-01-20 13:04 . import binutils-2.30-73.el8.src.rpm
--- binutils.orig/bfd/elfxx-x86.c 2018-05-14 12:22:29.149657093 +0100
+++ binutils-2.30/bfd/elfxx-x86.c 2018-05-14 12:25:16.244700009 +0100
@@ -839,6 +839,33 @@ _bfd_x86_elf_compare_relocs (const void
return 0;
}
+/* Mark symbol, NAME, as locally defined by linker if it is referenced
+ and not defined in a relocatable object file. */
+
+static void
+elf_x86_linker_defined (struct bfd_link_info *info, const char *name)
+{
+ struct elf_link_hash_entry *h;
+
+ h = elf_link_hash_lookup (elf_hash_table (info), name,
+ FALSE, FALSE, FALSE);
+ if (h == NULL)
+ return;
+
+ while (h->root.type == bfd_link_hash_indirect)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+
+ if (h->root.type == bfd_link_hash_new
+ || h->root.type == bfd_link_hash_undefined
+ || h->root.type == bfd_link_hash_undefweak
+ || h->root.type == bfd_link_hash_common
+ || (!h->def_regular && h->def_dynamic))
+ {
+ elf_x86_hash_entry (h)->local_ref = 2;
+ elf_x86_hash_entry (h)->linker_def = 1;
+ }
+}
+
bfd_boolean
_bfd_x86_elf_link_check_relocs (bfd *abfd, struct bfd_link_info *info)
{
@@ -869,18 +896,16 @@ _bfd_x86_elf_link_check_relocs (bfd *abf
/* "__ehdr_start" will be defined by linker as a hidden symbol
later if it is referenced and not defined. */
- h = elf_link_hash_lookup (elf_hash_table (info),
- "__ehdr_start",
- FALSE, FALSE, FALSE);
- if (h != NULL
- && (h->root.type == bfd_link_hash_new
- || h->root.type == bfd_link_hash_undefined
- || h->root.type == bfd_link_hash_undefweak
- || h->root.type == bfd_link_hash_common))
+ elf_x86_linker_defined (info, "__ehdr_start");
+
+ if (bfd_link_executable (info))
{
- elf_x86_hash_entry (h)->local_ref = 2;
- elf_x86_hash_entry (h)->linker_def = 1;
- }
+ /* References to __bss_start, _end and _edata should be
+ locally resolved within executables. */
+ elf_x86_linker_defined (info, "__bss_start");
+ elf_x86_linker_defined (info, "_end");
+ elf_x86_linker_defined (info, "_edata");
+ }
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lixing-loongson-cn/binutils_anolis.git
git@gitee.com:lixing-loongson-cn/binutils_anolis.git
lixing-loongson-cn
binutils_anolis
binutils_anolis
a8

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385