aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormengqinggang <mengqinggang@loongson.cn>2024-05-30 19:52:34 +0800
committerliuzhensong <liuzhensong@loongson.cn>2024-06-04 19:47:27 +0800
commit07284e5ee02c51f3df2ea8fe2370ca3d1d42d84d (patch)
treeec2bf6dc7d59a6404db287561608ddfec7aabfa2 /ld/emultempl
parentLoongArch: Make align symbol be in same section with alignment directive (diff)
downloadbinutils-gdb-07284e5ee02c51f3df2ea8fe2370ca3d1d42d84d.tar.gz
binutils-gdb-07284e5ee02c51f3df2ea8fe2370ca3d1d42d84d.tar.bz2
binutils-gdb-07284e5ee02c51f3df2ea8fe2370ca3d1d42d84d.zip
LoongArch: Disable linker relaxation if set the address of section or segment
If set the address of section or segment, the offset from pc to symbol may become bigger and cause overflow.
Diffstat (limited to 'ld/emultempl')
-rw-r--r--ld/emultempl/loongarchelf.em16
1 files changed, 16 insertions, 0 deletions
diff --git a/ld/emultempl/loongarchelf.em b/ld/emultempl/loongarchelf.em
index 3bb5ddf0db4..2da40582008 100644
--- a/ld/emultempl/loongarchelf.em
+++ b/ld/emultempl/loongarchelf.em
@@ -25,6 +25,22 @@ fragment <<EOF
#include "elf/loongarch.h"
#include "elfxx-loongarch.h"
+EOF
+
+# Disable linker relaxation if set address of section or segment.
+PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
+ case OPTION_SECTION_START:
+ case OPTION_TTEXT:
+ case OPTION_TBSS:
+ case OPTION_TDATA:
+ case OPTION_TTEXT_SEGMENT:
+ case OPTION_TRODATA_SEGMENT:
+ case OPTION_TLDATA_SEGMENT:
+ link_info.disable_target_specific_optimizations = 2;
+ return false;
+'
+
+fragment <<EOF
static void
larch_elf_before_allocation (void)
{