Changeset 2967 for trunk/kLdr/testcase
- Timestamp:
- Feb 13, 2007, 11:28:46 PM (19 years ago)
- Location:
- trunk/kLdr/testcase
- Files:
-
- 3 added
- 3 edited
- 3 copied
-
Makefile.kmk (modified) (2 diffs)
-
bin (added)
-
bin/tst-3.dll.win.x86 (added)
-
bin/tst-3.rel.darwin.x86 (added)
-
tst-3-driver.c (modified) (4 diffs)
-
tst-3-ext.c (copied) (copied from trunk/kLdr/testcase/tst-3.c ) (2 diffs)
-
tst-3-imp-os2.def (copied) (copied from trunk/kLdr/testcase/tst-3.c ) (1 diff)
-
tst-3-imp-win.def (copied) (copied from trunk/kLdr/testcase/tst-3.c ) (1 diff)
-
tst-3.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/kLdr/testcase/Makefile.kmk
r2965 r2967 121 121 TEMPLATE_TSTBARE_DEFS = __DARWIN__ 122 122 TEMPLATE_TSTBARE_LIBS = 123 TEMPLATE_TSTBARE_CFLAGS += -static 123 TEMPLATE_TSTBARE_CFLAGS += -static 124 124 TEMPLATE_TSTBARE_LDFLAGS += -nostdlib -r 125 125 else … … 270 270 # 271 271 PROGRAMS += tst-3-driver 272 273 274 272 275 DLLS += tst-3 276 277 278 273 279 274 280 tst-3_TEMPLATE = TSTBAREDLL 275 tst-3_SOURCES = tst-3.c tst DllMainStub.c281 tst-3_SOURCES = tst-3.c tstDllMainStub.c 276 282 tst-3_SOURCES.os2= tstDllMainStub-os2.asm 283 284 285 286 287 288 277 289 278 290 tst-3-driver_TEMPLATE = TSTPROG -
trunk/kLdr/testcase/tst-3-driver.c
r2965 r2967 72 72 73 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 74 88 static int GetImport(PKLDRMOD pMod, uint32_t iImport, uint32_t iSymbol, const char *pchSymbol, size_t cchSymbol, 75 89 const char *pszVersion, PKLDRADDR puValue, uint32_t *pfKind, void *pvUser) 76 90 { 77 /** todo */ 78 return -1; 91 if (*pfKind != KLDRSYMKIND_REQ_FLAT) 92 return -1; 93 94 if ( !strncmp(pchSymbol, "Tst3Ext", strlen("Tst3Ext")) 95 || !strncmp(pchSymbol, "_Tst3Ext", strlen("_Tst3Ext"))) 96 { 97 *puValue = (uintptr_t)&Tst3Ext; 98 *pfKind = KLDRSYMKIND_CODE | (sizeof(pfKind) == 4 ? KLDRSYMKIND_32BIT : KLDRSYMKIND_64BIT); 99 return 0; 100 } 101 102 return -2; 79 103 } 80 104 … … 100 124 /* get bits. */ 101 125 cbImage = kLdrModSize(pMod); 102 pvBits = malloc((size_t)cbImage );126 pvBits = malloc((size_t)cbImage); 103 127 if (pvBits) 104 128 { 105 KLDRADDR BaseAddress = (uintptr_t)pvBits; 106 rc = kLdrModGetBits(pMod, pvBits, BaseAddress, GetImport, NULL); 129 void *pvBits2 = (void *)( ((uintptr_t)pvBits + 0xfff) & ~(uintptr_t)0xfff ); 130 131 KLDRADDR BaseAddress = (uintptr_t)pvBits2; 132 rc = kLdrModGetBits(pMod, pvBits2, BaseAddress, GetImport, NULL); 107 133 if (!rc) 108 134 { 109 const char *pszSym = MY_NAME("Tst3");110 135 KLDRADDR EntryPoint; 111 136 112 137 /* call into it */ 113 rc = kLdrModQuerySymbol(pMod, pvBits , BaseAddress, NIL_KLDRMOD_SYM_ORDINAL, pszSym, strlen(pszSym), NULL, NULL, NULL,138 rc = kLdrModQuerySymbol(pMod, pvBits), NULL, NULL, NULL, 114 139 &EntryPoint, NULL); 140 141 142 115 143 if (!rc) 116 144 { … … 120 148 { 121 149 /* relocate twice and try again. */ 122 rc = kLdrModRelocateBits(pMod, pvBits , BaseAddress + 0x22000, BaseAddress, GetImport, NULL);150 rc = kLdrModRelocateBits(pMod, pvBits, BaseAddress + 0x22000, BaseAddress, GetImport, NULL); 123 151 if (!rc) 124 152 { 125 rc = kLdrModRelocateBits(pMod, pvBits , BaseAddress, BaseAddress + 0x22000, GetImport, NULL);153 rc = kLdrModRelocateBits(pMod, pvBits, BaseAddress, BaseAddress + 0x22000, GetImport, NULL); 126 154 if (!rc) 127 155 { … … 178 206 */ 179 207 if (!g_cErrors) 180 printf("tst- 0-driver: SUCCESS\n");208 printf("tst--driver: SUCCESS\n"); 181 209 else 182 printf("tst- 0-driver: FAILURE - %d errors\n", g_cErrors);210 printf("tst--driver: FAILURE - %d errors\n", g_cErrors); 183 211 return !!g_cErrors; 184 212 } -
trunk/kLdr/testcase/tst-3-ext.c
r2965 r2967 2 2 /** @file 3 3 * 4 * kLdr - Dynamic Loader testcase no. 3, Driver.4 * kLdr - Dynamic Loader testcase no. 3, . 5 5 * 6 6 * Copyright (c) 2006 knut st. osmundsen <[email protected]> … … 28 28 #include "tst.h" 29 29 30 31 int g_i1 = 1; 32 int g_i2 = 2; 33 int *g_pi1 = &g_i1; 34 35 int Tst3Sub(int); 36 int (*g_pfnTst3Sub)(int) = &Tst3Sub; 37 38 char g_achBss[256]; 39 40 41 MY_EXPORT(int) Tst3(int iFortyTwo) 42 { 43 int rc; 44 45 if (iFortyTwo != 42) 46 return 0; 47 if (g_i1 != 1) 48 return 1; 49 if (g_i2 != 2) 50 return 2; 51 if (g_pi1 != &g_i1) 52 return 3; 53 if (g_pfnTst3Sub != &Tst3Sub) 54 return 4; 55 rc = Tst3Sub(iFortyTwo); 56 if (rc != g_pfnTst3Sub(iFortyTwo)) 57 return 5; 58 for (rc = 0; rc < sizeof(g_achBss); rc++) 59 if (g_achBss[rc]) 60 return 6; 61 if (g_achBss[0] || g_achBss[1] || g_achBss[255]) 62 return 7; 63 64 return 42; 65 } 66 30 extern int g_i1; 67 31 68 32 int Tst3Sub(int iFortyTwo) 69 33 { 70 return iFortyTwo * 11 ;34 return iFortyTwo * 11; 71 35 } 72 36 -
trunk/kLdr/testcase/tst-3-imp-os2.def
r2965 r2967 1 /* $Id$ */ 2 /**@file3 * 4 * kLdr - Dynamic Loader testcase no. 3, Driver.5 * 6 *Copyright (c) 2006 knut st. osmundsen <[email protected]>7 * 8 * 9 *This file is part of kLdr.10 * 11 *kLdr is free software; you can redistribute it and/or modify12 *it under the terms of the GNU General Public License as published by13 *the Free Software Foundation; either version 2 of the License, or14 *(at your option) any later version.15 * 16 *kLdr is distributed in the hope that it will be useful,17 *but WITHOUT ANY WARRANTY; without even the implied warranty of18 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 *GNU General Public License for more details.20 * 21 *You should have received a copy of the GNU General Public License22 *along with kLdr; if not, write to the Free Software23 *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA24 * 25 */ 1 ; $Id$ 2 @file 3 ; 4 . 5 ; 6 Copyright (c) 2006 knut st. osmundsen <[email protected]> 7 ; 8 ; 9 This file is part of kLdr. 10 ; 11 kLdr is free software; you can redistribute it and/or modify 12 it under the terms of the GNU General Public License as published by 13 the Free Software Foundation; either version 2 of the License, or 14 (at your option) any later version. 15 ; 16 kLdr is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License for more details. 20 ; 21 You should have received a copy of the GNU General Public License 22 along with kLdr; if not, write to the Free Software 23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 ; 25 ; 26 26 27 28 29 27 30 28 #include "tst.h"29 30 31 int g_i1 = 1;32 int g_i2 = 2;33 int *g_pi1 = &g_i1;34 35 int Tst3Sub(int);36 int (*g_pfnTst3Sub)(int) = &Tst3Sub;37 38 char g_achBss[256];39 40 41 MY_EXPORT(int) Tst3(int iFortyTwo)42 {43 int rc;44 45 if (iFortyTwo != 42)46 return 0;47 if (g_i1 != 1)48 return 1;49 if (g_i2 != 2)50 return 2;51 if (g_pi1 != &g_i1)52 return 3;53 if (g_pfnTst3Sub != &Tst3Sub)54 return 4;55 rc = Tst3Sub(iFortyTwo);56 if (rc != g_pfnTst3Sub(iFortyTwo))57 return 5;58 for (rc = 0; rc < sizeof(g_achBss); rc++)59 if (g_achBss[rc])60 return 6;61 if (g_achBss[0] || g_achBss[1] || g_achBss[255])62 return 7;63 64 return 42;65 }66 67 68 int Tst3Sub(int iFortyTwo)69 {70 return iFortyTwo * 11;71 }72 -
trunk/kLdr/testcase/tst-3-imp-win.def
r2965 r2967 1 /* $Id$ */ 2 /**@file3 * 4 * kLdr - Dynamic Loader testcase no. 3, Driver.5 * 6 *Copyright (c) 2006 knut st. osmundsen <[email protected]>7 * 8 * 9 *This file is part of kLdr.10 * 11 *kLdr is free software; you can redistribute it and/or modify12 *it under the terms of the GNU General Public License as published by13 *the Free Software Foundation; either version 2 of the License, or14 *(at your option) any later version.15 * 16 *kLdr is distributed in the hope that it will be useful,17 *but WITHOUT ANY WARRANTY; without even the implied warranty of18 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the19 *GNU General Public License for more details.20 * 21 *You should have received a copy of the GNU General Public License22 *along with kLdr; if not, write to the Free Software23 *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA24 * 25 */ 1 ; $Id$ 2 @file 3 ; 4 . 5 ; 6 Copyright (c) 2006 knut st. osmundsen <[email protected]> 7 ; 8 ; 9 This file is part of kLdr. 10 ; 11 kLdr is free software; you can redistribute it and/or modify 12 it under the terms of the GNU General Public License as published by 13 the Free Software Foundation; either version 2 of the License, or 14 (at your option) any later version. 15 ; 16 kLdr is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License for more details. 20 ; 21 You should have received a copy of the GNU General Public License 22 along with kLdr; if not, write to the Free Software 23 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 ; 25 ; 26 26 27 28 29 27 30 28 #include "tst.h"29 30 31 int g_i1 = 1;32 int g_i2 = 2;33 int *g_pi1 = &g_i1;34 35 int Tst3Sub(int);36 int (*g_pfnTst3Sub)(int) = &Tst3Sub;37 38 char g_achBss[256];39 40 41 MY_EXPORT(int) Tst3(int iFortyTwo)42 {43 int rc;44 45 if (iFortyTwo != 42)46 return 0;47 if (g_i1 != 1)48 return 1;49 if (g_i2 != 2)50 return 2;51 if (g_pi1 != &g_i1)52 return 3;53 if (g_pfnTst3Sub != &Tst3Sub)54 return 4;55 rc = Tst3Sub(iFortyTwo);56 if (rc != g_pfnTst3Sub(iFortyTwo))57 return 5;58 for (rc = 0; rc < sizeof(g_achBss); rc++)59 if (g_achBss[rc])60 return 6;61 if (g_achBss[0] || g_achBss[1] || g_achBss[255])62 return 7;63 64 return 42;65 }66 67 68 int Tst3Sub(int iFortyTwo)69 {70 return iFortyTwo * 11;71 }72 -
trunk/kLdr/testcase/tst-3.c
r2965 r2967 33 33 int *g_pi1 = &g_i1; 34 34 35 int Tst3Sub(int);35 int Tst3Sub(int); 36 36 int (*g_pfnTst3Sub)(int) = &Tst3Sub; 37 38 39 37 40 38 41 char g_achBss[256]; … … 56 59 if (rc != g_pfnTst3Sub(iFortyTwo)) 57 60 return 5; 61 62 63 64 65 66 58 67 for (rc = 0; rc < sizeof(g_achBss); rc++) 59 68 if (g_achBss[rc]) 60 return 6;69 return ; 61 70 if (g_achBss[0] || g_achBss[1] || g_achBss[255]) 62 return 7;71 return ; 63 72 64 73 return 42; 65 74 } 66 75 67 68 int Tst3Sub(int iFortyTwo)69 {70 return iFortyTwo * 11;71 }72
Note:
See TracChangeset
for help on using the changeset viewer.
