Page MenuHomeFreeBSD

D62499.1796556968.diff
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

D62499.1796556968.diff

diff --git a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
--- a/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
+++ b/cddl/contrib/opensolaris/lib/libdtrace/common/dt_link.c
@@ -68,7 +68,11 @@
".SUNW_dof\0" /* 11 */
".strtab\0" /* 21 */
".symtab\0" /* 29 */
+#if defined(__powerpc__)
+".rela.SUNW_dof"; /* 37 */
+#else
".rel.SUNW_dof"; /* 37 */
+#endif
static const char DTRACE_SHSTRTAB64[] = "\0"
".shstrtab\0" /* 1 */
@@ -88,7 +92,11 @@
typedef struct dof_elf32 {
uint32_t de_nrel; /* relocation count */
+#if defined(__powerpc__)
+ Elf32_Rela *de_rel; /* array of relocations for powerpc */
+#else
Elf32_Rel *de_rel; /* array of relocations for x86 */
+#endif
uint32_t de_nsym; /* symbol count */
Elf32_Sym *de_sym; /* array of symbols */
uint32_t de_strlen; /* size of of string table */
@@ -108,7 +116,11 @@
uint32_t count = 0;
size_t base;
Elf32_Sym *sym;
+#if defined(__powerpc__)
+ Elf32_Rela *rel;
+#else
Elf32_Rel *rel;
+#endif
/*LINTED*/
dofs = (dof_sec_t *)((char *)dof + dof->dofh_secoff);
@@ -218,12 +230,14 @@
#elif defined(__powerpc__)
/*
* Add 4 bytes to hit the low half of this 64-bit
- * big-endian address.
+ * big-endian address. The relocation is relative to
+ * the place it is applied to, hence the addend.
*/
rel->r_offset = s->dofs_offset +
dofr[j].dofr_offset + 4;
rel->r_info = ELF32_R_INFO(count + dep->de_global,
R_PPC_REL32);
+ rel->r_addend = 4;
#elif defined(__riscv)
rel->r_offset = s->dofs_offset + dofr[j].dofr_offset;
rel->r_info = ELF32_R_INFO(count + dep->de_global,
@@ -583,7 +597,11 @@
shp = &elf_file.shdr[ESHDR_REL];
shp->sh_name = 37; /* DTRACE_SHSTRTAB32[37] = ".rel.SUNW_dof" */
shp->sh_flags = 0;
+#if defined(__powerpc__)
+ shp->sh_type = SHT_RELA;
+#else
shp->sh_type = SHT_REL;
+#endif
shp->sh_entsize = sizeof (de.de_rel[0]);
shp->sh_link = ESHDR_SYMTAB;
shp->sh_info = ESHDR_DOF;
@@ -907,14 +925,13 @@
*/
if (isenabled) {
if (ip[0] == DT_OP_XOR_R3) {
- (*off) += sizeof (ip[0]);
+ if (dtp->dt_oflags & DTRACE_O_LP64)
+ (*off) += sizeof (ip[0]);
return (0);
}
} else {
- if (ip[0] == DT_OP_NOP) {
- (*off) += sizeof (ip[0]);
+ if (ip[0] == DT_OP_NOP)
return (0);
- }
}
/*
@@ -939,8 +956,13 @@
return (-1);
}
+ /*
+ * In 64-bit code the tracepoint goes on the nop that follows
+ * the call. 32-bit code has no such nop.
+ */
ip[0] = DT_OP_XOR_R3;
- (*off) += sizeof (ip[0]);
+ if (dtp->dt_oflags & DTRACE_O_LP64)
+ (*off) += sizeof (ip[0]);
} else {
if (DT_IS_BL(ip[0]))
ip[0] = DT_OP_NOP;

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 6, 11:36 AM (22 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42254772
Default Alt Text
D62499.1796556968.diff (2 KB)

Event Timeline