This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] MIPS: Use R_MICROMIPS_JALR rather than R_MIPS_JALR in microMIPS code
- From: "Maciej W. Rozycki" <macro at imgtec dot com>
- To: <libc-alpha at sourceware dot org>
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>
- Date: Wed, 23 Nov 2016 12:39:39 +0000
- Subject: [PATCH] MIPS: Use R_MICROMIPS_JALR rather than R_MIPS_JALR in microMIPS code
- Authentication-results: sourceware.org; auth=none
In a microMIPS compilation of `.init' code use the R_MICROMIPS_JALR
relocation intended for PIC call relaxation in microMIPS code rather
than the corresponding R_MIPS_JALR relocation meant for regular MIPS
code only.
* sysdeps/mips/mips32/crti.S (JALR_RELOC): New macro.
(_init): Use it in place of hardcoded R_MIPS_JALR.
* sysdeps/mips/mips64/n32/crti.S (JALR_RELOC): New macro.
(_init): Use it in place of hardcoded R_MIPS_JALR.
* sysdeps/mips/mips64/n64/crti.S (JALR_RELOC): New macro.
(_init): Use it in place of hardcoded R_MIPS_JALR.
---
No regressions with the `mips-mti-linux-gnu' target in o32 regular MIPS
and microMIPS multilib testing and neither in n32 and n64 regular MIPS
multilib testing.
OK to apply?
Maciej
glibc-umips-jalr.diff
Index: glibc/sysdeps/mips/mips32/crti.S
===================================================================
--- glibc.orig/sysdeps/mips/mips32/crti.S 2016-11-17 15:28:32.000000000 +0000
+++ glibc/sysdeps/mips/mips32/crti.S 2016-11-17 15:36:52.838901381 +0000
@@ -40,6 +40,12 @@
#include <libc-symbols.h>
+#ifdef __mips_micromips
+# define JALR_RELOC R_MICROMIPS_JALR
+#else
+# define JALR_RELOC R_MIPS_JALR
+#endif
+
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
@@ -71,13 +77,13 @@
lw $2,%got(PREINIT_FUNCTION)($28)
beq $2,$0,.Lno_weak_fn
lw $25,%call16(PREINIT_FUNCTION)($28)
- .reloc 1f,R_MIPS_JALR,PREINIT_FUNCTION
+ .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
1: jalr $25
.Lno_weak_fn:
.insn
#else
lw $25,%got(PREINIT_FUNCTION)($28)
- .reloc 1f,R_MIPS_JALR,PREINIT_FUNCTION
+ .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
1: jalr $25
#endif
Index: glibc/sysdeps/mips/mips64/n32/crti.S
===================================================================
--- glibc.orig/sysdeps/mips/mips64/n32/crti.S 2016-11-17 15:30:48.000000000 +0000
+++ glibc/sysdeps/mips/mips64/n32/crti.S 2016-11-17 15:37:17.195020438 +0000
@@ -40,6 +40,12 @@
#include <libc-symbols.h>
+#ifdef __mips_micromips
+# define JALR_RELOC R_MICROMIPS_JALR
+#else
+# define JALR_RELOC R_MIPS_JALR
+#endif
+
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
@@ -71,13 +77,13 @@
lw $2,%got_disp(PREINIT_FUNCTION)($28)
beq $2,$0,.Lno_weak_fn
lw $25,%call16(PREINIT_FUNCTION)($28)
- .reloc 1f,R_MIPS_JALR,PREINIT_FUNCTION
+ .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
1: jalr $25
.Lno_weak_fn:
.insn
#else
lw $25,%got_disp(PREINIT_FUNCTION)($28)
- .reloc 1f,R_MIPS_JALR,PREINIT_FUNCTION
+ .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
1: jalr $25
#endif
Index: glibc/sysdeps/mips/mips64/n64/crti.S
===================================================================
--- glibc.orig/sysdeps/mips/mips64/n64/crti.S 2016-11-17 15:30:56.000000000 +0000
+++ glibc/sysdeps/mips/mips64/n64/crti.S 2016-11-17 15:38:09.690102763 +0000
@@ -40,6 +40,12 @@
#include <libc-symbols.h>
+#ifdef __mips_micromips
+# define JALR_RELOC R_MICROMIPS_JALR
+#else
+# define JALR_RELOC R_MIPS_JALR
+#endif
+
#ifndef PREINIT_FUNCTION
# define PREINIT_FUNCTION __gmon_start__
#endif
@@ -71,13 +77,13 @@
ld $2,%got_disp(PREINIT_FUNCTION)($28)
beq $2,$0,.Lno_weak_fn
ld $25,%call16(PREINIT_FUNCTION)($28)
- .reloc 1f,R_MIPS_JALR,PREINIT_FUNCTION
+ .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
1: jalr $25
.Lno_weak_fn:
.insn
#else
ld $25,%got_disp(PREINIT_FUNCTION)($28)
- .reloc 1f,R_MIPS_JALR,PREINIT_FUNCTION
+ .reloc 1f,JALR_RELOC,PREINIT_FUNCTION
1: jalr $25
#endif