dt_link.c (228549) | dt_link.c (256543) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 228 unchanged lines hidden (view full) --- 237 rel->r_offset = s->dofs_offset + 238 dofr[j].dofr_offset; 239 rel->r_info = ELF32_R_INFO(count + dep->de_global, 240 R_386_32); 241#elif defined(__mips__) 242/* XXX */ 243printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); 244#elif defined(__powerpc__) | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 228 unchanged lines hidden (view full) --- 237 rel->r_offset = s->dofs_offset + 238 dofr[j].dofr_offset; 239 rel->r_info = ELF32_R_INFO(count + dep->de_global, 240 R_386_32); 241#elif defined(__mips__) 242/* XXX */ 243printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); 244#elif defined(__powerpc__) |
245/* XXX */ 246printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); | 245 /* 246 * Add 4 bytes to hit the low half of this 64-bit 247 * big-endian address. 248 */ 249 rel->r_offset = s->dofs_offset + 250 dofr[j].dofr_offset + 4; 251 rel->r_info = ELF32_R_INFO(count + dep->de_global, 252 R_PPC_REL32); |
247#elif defined(__sparc) 248 /* 249 * Add 4 bytes to hit the low half of this 64-bit 250 * big-endian address. 251 */ 252 rel->r_offset = s->dofs_offset + 253 dofr[j].dofr_offset + 4; 254 rel->r_info = ELF32_R_INFO(count + dep->de_global, --- 163 unchanged lines hidden (view full) --- 418#ifdef DOODAD 419#if defined(__arm__) 420/* XXX */ 421#elif defined(__ia64__) 422/* XXX */ 423#elif defined(__mips__) 424/* XXX */ 425#elif defined(__powerpc__) | 253#elif defined(__sparc) 254 /* 255 * Add 4 bytes to hit the low half of this 64-bit 256 * big-endian address. 257 */ 258 rel->r_offset = s->dofs_offset + 259 dofr[j].dofr_offset + 4; 260 rel->r_info = ELF32_R_INFO(count + dep->de_global, --- 163 unchanged lines hidden (view full) --- 424#ifdef DOODAD 425#if defined(__arm__) 426/* XXX */ 427#elif defined(__ia64__) 428/* XXX */ 429#elif defined(__mips__) 430/* XXX */ 431#elif defined(__powerpc__) |
426/* XXX */ | 432 rel->r_offset = s->dofs_offset + 433 dofr[j].dofr_offset; 434 rel->r_info = ELF64_R_INFO(count + dep->de_global, 435 R_PPC64_REL64); |
427#elif defined(__i386) || defined(__amd64) 428 rel->r_offset = s->dofs_offset + 429 dofr[j].dofr_offset; 430 rel->r_info = ELF64_R_INFO(count + dep->de_global, 431 R_AMD64_64); 432#elif defined(__sparc) 433 rel->r_offset = s->dofs_offset + 434 dofr[j].dofr_offset; --- 384 unchanged lines hidden (view full) --- 819static int 820dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, 821 uint32_t *off) 822{ 823printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); 824 return (0); 825} 826#elif defined(__powerpc__) | 436#elif defined(__i386) || defined(__amd64) 437 rel->r_offset = s->dofs_offset + 438 dofr[j].dofr_offset; 439 rel->r_info = ELF64_R_INFO(count + dep->de_global, 440 R_AMD64_64); 441#elif defined(__sparc) 442 rel->r_offset = s->dofs_offset + 443 dofr[j].dofr_offset; --- 384 unchanged lines hidden (view full) --- 828static int 829dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, 830 uint32_t *off) 831{ 832printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); 833 return (0); 834} 835#elif defined(__powerpc__) |
836/* The sentinel is 'xor r3,r3,r3'. */ 837#define DT_OP_XOR_R3 0x7c631a78 838 839#define DT_OP_NOP 0x60000000 840#define DT_OP_BLR 0x4e800020 841 842/* This captures all forms of branching to address. */ 843#define DT_IS_BRANCH(inst) ((inst & 0xfc000000) == 0x48000000) 844#define DT_IS_BL(inst) (DT_IS_BRANCH(inst) && (inst & 0x01)) 845 |
|
827/* XXX */ 828static int 829dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, 830 uint32_t *off) 831{ | 846/* XXX */ 847static int 848dt_modtext(dtrace_hdl_t *dtp, char *p, int isenabled, GElf_Rela *rela, 849 uint32_t *off) 850{ |
832printf("%s:%s(%d): DOODAD\n",__FUNCTION__,__FILE__,__LINE__); | 851 uint32_t *ip; 852 853 if ((rela->r_offset & (sizeof (uint32_t) - 1)) != 0) 854 return (-1); 855 856 /*LINTED*/ 857 ip = (uint32_t *)(p + rela->r_offset); 858 859 /* 860 * We only know about some specific relocation types. 861 */ 862 if (GELF_R_TYPE(rela->r_info) != R_PPC_REL24 && 863 GELF_R_TYPE(rela->r_info) != R_PPC_PLTREL24) 864 return (-1); 865 866 /* 867 * We may have already processed this object file in an earlier linker 868 * invocation. Check to see if the present instruction sequence matches 869 * the one we would install below. 870 */ 871 if (isenabled) { 872 if (ip[0] == DT_OP_XOR_R3) { 873 (*off) += sizeof (ip[0]); 874 return (0); 875 } 876 } else { 877 if (ip[0] == DT_OP_NOP) { 878 (*off) += sizeof (ip[0]); 879 return (0); 880 } 881 } 882 883 /* 884 * We only expect branch to address instructions. 885 */ 886 if (!DT_IS_BRANCH(ip[0])) { 887 dt_dprintf("found %x instead of a branch instruction at %llx\n", 888 ip[0], (u_longlong_t)rela->r_offset); 889 return (-1); 890 } 891 892 if (isenabled) { 893 /* 894 * It would necessarily indicate incorrect usage if an is- 895 * enabled probe were tail-called so flag that as an error. 896 * It's also potentially (very) tricky to handle gracefully, 897 * but could be done if this were a desired use scenario. 898 */ 899 if (!DT_IS_BL(ip[0])) { 900 dt_dprintf("tail call to is-enabled probe at %llx\n", 901 (u_longlong_t)rela->r_offset); 902 return (-1); 903 } 904 905 ip[0] = DT_OP_XOR_R3; 906 (*off) += sizeof (ip[0]); 907 } else { 908 if (DT_IS_BL(ip[0])) 909 ip[0] = DT_OP_NOP; 910 else 911 ip[0] = DT_OP_BLR; 912 } 913 |
833 return (0); 834} 835 836#elif defined(__sparc) 837 838#define DT_OP_RET 0x81c7e008 839#define DT_OP_NOP 0x01000000 840#define DT_OP_CALL 0x40000000 --- 1132 unchanged lines hidden --- | 914 return (0); 915} 916 917#elif defined(__sparc) 918 919#define DT_OP_RET 0x81c7e008 920#define DT_OP_NOP 0x01000000 921#define DT_OP_CALL 0x40000000 --- 1132 unchanged lines hidden --- |