Skip to contentSkip to conversation

ARC: Support R_ARC_JMP_SLOT relocations during bootstrap

PATCH New Vineet Gupta 1 participant 1 message Aug 8, 2016 1 message not in the archive Synopsys ARC architecture

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 ARC: Support R_ARC_JMP_SLOT relocations during bootstrap

Quoted 53 lines · Andrew Burgess

I ran into this issue while trying to debug a _different_ issue witin the uClinc(-ng) arc dynamic linker. I turned on debugging support within the dynamic linker, and the linker would no longer complete its bootstrap phase due to a lack of support for the R_ARC_JMP_SLOT relocation type.

To reproduce this issue it should be enough to configure uClibc(-ng) for ARC with 'DODEBUG=y', then try to run anything that requires dynamic linking.

The R_ARC_JMP_SLOT relocation type is used within the .plt, so I believe it makes sense for these relocations to be generated.

I updated the associated comment above the boostrap patching code so that it makes more sense (to me at least) with the extra relocation support.

I wonder if you would consider merging this patch?

Thanks,
Andrew

---

This commit adds support for R_ARC_JMP_SLOT relocations during the bootstrap phase of the dynamic linker. These relocations will be generated if uClibc is configured with 'DODEBUG=y'.

---
 ldso/ldso/arc/dl-startup.h | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
ldso/ldso/arc/dl-startup.h +5 -4
index ef89b53..fadc433 100644
@@ -64,10 +64,11 @@ __asm__(
 
 /*
  * Dynamic loader bootstrapping:
- * Since we don't modify text at runtime, these can only be data relos
- * (so safe to assume that they are word aligned).
- * And also they HAVE to be RELATIVE relos only
- * @RELP is the relo entry being processed
+ * The only relocations that should be found are either R_ARC_RELATIVE for
+ * data relocations (.got, etc) or R_ARC_JMP_SLOT for code relocations
+ * (.plt).  It is safe to assume that all of these relocations are word
+ * aligned.
+ * @RELP is the reloc entry being processed
  * @REL is the pointer to the address we are relocating.
  * @SYMBOL is the symbol involved in the relocation
  * @LOAD is the load address.

ldso/ldso/arc/dl-startup.h do { \ · line 86

Quoted 8 lines
ldso/ldso/arc/dl-startup.h +2 -0
@@ -78,6 +79,8 @@ do {									\
 	int type = ELF32_R_TYPE((RELP)->r_info);			\
 	if (likely(type == R_ARC_RELATIVE))				\
 		*REL += (unsigned long) LOAD;				\
+	else if (type == R_ARC_JMP_SLOT)                                \
+		*REL = SYMBOL;						\
 	else								\
 		_dl_exit(1);						\
 }while(0)

So I know this has been merged and all - but I'm wondering if this is PIE safe. Cuper has been painfully fixing PIE related issues - including uClibc issues and since we are on the topic I'm wondering if this needs some additional fixup ?

-Vineet