1 /* |
|
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. |
|
8 * |
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
|
13 * accompanied this code). |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License version |
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 * |
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 */ |
|
23 |
|
24 #include "jdk_tools_jaotc_jnilibelf_JNILibELFAPI.h" |
|
25 |
|
26 // For file open and close |
|
27 #include <fcntl.h> |
|
28 #include <unistd.h> |
|
29 #include <err.h> |
|
30 #include <sysexits.h> |
|
31 #include <stdlib.h> |
|
32 #include <string.h> |
|
33 |
|
34 #include <assert.h> |
|
35 |
|
36 // For libelf interfaces |
|
37 #include <libelf.h> |
|
38 #include <gelf.h> |
|
39 |
|
40 // Convenience macro to shut the compiler warnings |
|
41 #ifdef UNUSED |
|
42 #elif defined(__GNUC__) |
|
43 # define UNUSED(x) UNUSED_ ## x __attribute__((unused)) |
|
44 #elif defined(__LCLINT__) |
|
45 # define UNUSED(x) /*@unused@*/ x |
|
46 #else |
|
47 # define UNUSED(x) x |
|
48 #endif |
|
49 |
|
50 /** |
|
51 * libelfshim version |
|
52 */ |
|
53 #ifndef AOT_VERSION_STRING |
|
54 #error AOT_VERSION_STRING must be defined |
|
55 #endif |
|
56 |
|
57 JNIEXPORT jstring JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_elfshim_1version |
|
58 (JNIEnv* env, jclass UNUSED(c)) { |
|
59 const char* ver = AOT_VERSION_STRING; |
|
60 return (*env)->NewStringUTF(env, ver); |
|
61 } |
|
62 |
|
63 JNIEXPORT jint JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_elf_1version |
|
64 (JNIEnv* UNUSED(env), jclass UNUSED(c), jint v) { |
|
65 return elf_version(v); |
|
66 } |
|
67 |
|
68 /** |
|
69 * Unbox the Pointer object the encapsulated native address. |
|
70 */ |
|
71 |
|
72 static jlong getNativeAddress(JNIEnv* env, jobject ptrObj) { |
|
73 jclass ptrClass; |
|
74 jfieldID fidNumber; |
|
75 jlong nativeAddress = -1; |
|
76 assert (ptrObj != NULL); |
|
77 // Get a reference to ptr object's class |
|
78 ptrClass = (*env)->GetObjectClass(env, ptrObj); |
|
79 |
|
80 // Get the Field ID of the instance variables "address" |
|
81 fidNumber = (*env)->GetFieldID(env, ptrClass, "address", "J"); |
|
82 if (fidNumber != NULL) { |
|
83 // Get the long given the Field ID |
|
84 nativeAddress = (*env)->GetLongField(env, ptrObj, fidNumber); |
|
85 } |
|
86 // fprintf(stderr, "Native address : %lx\n", nativeAddress); |
|
87 return nativeAddress; |
|
88 } |
|
89 |
|
90 /** |
|
91 * Box the nativeAddress as a Pointer object. |
|
92 */ |
|
93 static jobject makePointerObject(JNIEnv* env, jlong nativeAddr) { |
|
94 jclass ptrClass = (*env)->FindClass(env, "jdk/tools/jaotc/jnilibelf/Pointer"); |
|
95 // Call back constructor to allocate a Pointer object, with an int argument |
|
96 jmethodID constructorId = (*env)->GetMethodID(env, ptrClass, "<init>", "(J)V"); |
|
97 jobject retObj = (*env)->NewObject(env, ptrClass, constructorId, nativeAddr); |
|
98 return retObj; |
|
99 } |
|
100 |
|
101 JNIEXPORT jobject JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_elf_1begin |
|
102 (JNIEnv* env, jclass UNUSED(class), jint filedes, jint cmd, jobject ptrObj) { |
|
103 |
|
104 Elf* elfPtr = NULL; |
|
105 jlong addr = getNativeAddress(env, ptrObj); |
|
106 |
|
107 if (addr != -1) { |
|
108 // Call libelf function |
|
109 if ((elfPtr = elf_begin(filedes, cmd, (Elf *) addr)) == NULL) { |
|
110 errx(EX_SOFTWARE, "elf_begin() failed: %s.", elf_errmsg(-1)); |
|
111 } |
|
112 } else { |
|
113 fprintf(stderr, "Failed to get native address to call elf_begin()\n"); |
|
114 } |
|
115 |
|
116 return makePointerObject(env, (jlong) elfPtr); |
|
117 } |
|
118 |
|
119 JNIEXPORT jint JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_elf_1end |
|
120 (JNIEnv* env, jclass UNUSED(class), jobject ptrObj) { |
|
121 |
|
122 jlong addr = getNativeAddress(env, ptrObj); |
|
123 |
|
124 if (addr != -1) { |
|
125 // Call libelf function |
|
126 return elf_end((Elf *) addr); |
|
127 } else { |
|
128 fprintf(stderr, "Failed to get native address to call elf_end()\n"); |
|
129 return -1; |
|
130 } |
|
131 } |
|
132 |
|
133 JNIEXPORT jint JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_elf_1kind |
|
134 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj) { |
|
135 jlong addr = getNativeAddress(env, ptrObj); |
|
136 |
|
137 if (addr != -1) { |
|
138 // Call libelf function |
|
139 return elf_kind((Elf *) addr); |
|
140 } else { |
|
141 fprintf(stderr, "Failed to get native address to call elf_kind()\n"); |
|
142 return -1; |
|
143 } |
|
144 } |
|
145 JNIEXPORT jint JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_elf_1flagphdr |
|
146 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj, jint cmd, jint flags) { |
|
147 |
|
148 jlong addr = getNativeAddress(env, ptrObj); |
|
149 unsigned int retVal = 0; |
|
150 |
|
151 if (addr != -1) { |
|
152 // Call libelf function |
|
153 if ((retVal = elf_flagphdr((Elf *) addr, cmd, flags)) == 0) { |
|
154 errx(EX_SOFTWARE, "elf_flagphdr() failed: %s.", elf_errmsg(-1)); |
|
155 } |
|
156 } else { |
|
157 fprintf(stderr, "Failed to get native address to call elf_flagphdr()\n"); |
|
158 } |
|
159 return retVal; |
|
160 } |
|
161 |
|
162 JNIEXPORT jobject JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_elf_1newscn |
|
163 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj) { |
|
164 |
|
165 Elf_Scn* elfSecPtr = NULL; |
|
166 jlong addr = getNativeAddress(env, ptrObj); |
|
167 |
|
168 if (addr != -1) { |
|
169 // Call libelf function |
|
170 if ((elfSecPtr = elf_newscn((Elf *) addr)) == NULL) { |
|
171 errx(EX_SOFTWARE, "elf_newscn() failed: %s.", elf_errmsg(-1)); |
|
172 } |
|
173 } else { |
|
174 fprintf(stderr, "Failed to get native address to call elf_newscn()\n"); |
|
175 } |
|
176 |
|
177 return makePointerObject(env, (jlong) elfSecPtr); |
|
178 } |
|
179 |
|
180 JNIEXPORT jobject JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_elf_1newdata |
|
181 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj) { |
|
182 |
|
183 Elf_Data* elfDataPtr = NULL; |
|
184 jlong addr = getNativeAddress(env, ptrObj); |
|
185 |
|
186 if (addr != -1) { |
|
187 // Call libelf function |
|
188 if ((elfDataPtr = elf_newdata((Elf_Scn *) addr)) == NULL) { |
|
189 errx(EX_SOFTWARE, "elf_newdata() failed: %s.", elf_errmsg(-1)); |
|
190 } |
|
191 } else { |
|
192 fprintf(stderr, "Failed to get native address to call elf_newdata()\n"); |
|
193 } |
|
194 return makePointerObject(env, (jlong) elfDataPtr); |
|
195 } |
|
196 |
|
197 JNIEXPORT jobject JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_elf64_1getshdr |
|
198 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj) { |
|
199 |
|
200 Elf64_Shdr* elf64ShdrPtr = NULL; |
|
201 jlong addr = getNativeAddress(env, ptrObj); |
|
202 |
|
203 if (addr != -1) { |
|
204 // Call libelf function |
|
205 if ((elf64ShdrPtr = elf64_getshdr((Elf_Scn *) addr)) == NULL) { |
|
206 errx(EX_SOFTWARE, "elf64_getshdr() failed: %s.", elf_errmsg(-1)); |
|
207 } |
|
208 } else { |
|
209 fprintf(stderr, "Failed to get native address to call elf_getshdr()\n"); |
|
210 } |
|
211 return makePointerObject(env, (jlong) elf64ShdrPtr); |
|
212 } |
|
213 |
|
214 JNIEXPORT jlong JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_elf_1update |
|
215 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj, jint cmd) { |
|
216 |
|
217 off_t size = -1; |
|
218 jlong addr = getNativeAddress(env, ptrObj); |
|
219 |
|
220 if (addr != -1) { |
|
221 // Call libelf function |
|
222 if ((size = elf_update((Elf*) addr, cmd)) == -1) { |
|
223 errx(EX_SOFTWARE, "elf_update() failed: %s size (%d) cmd (%d).", elf_errmsg(-1), (int)size, cmd); |
|
224 } |
|
225 } else { |
|
226 fprintf(stderr, "Failed to get native address to call elf_update()\n"); |
|
227 } |
|
228 return size; |
|
229 } |
|
230 |
|
231 JNIEXPORT jstring JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_elf_1errmsg |
|
232 (JNIEnv* env, jclass UNUSED(c), jint errno) { |
|
233 |
|
234 const char * retPtr = NULL; |
|
235 // Call libelf function |
|
236 if ((retPtr = elf_errmsg(errno)) == NULL) { |
|
237 errx(EX_SOFTWARE, "elf_errmsg() failed: %s.", elf_errmsg(-1)); |
|
238 } |
|
239 return (*env)->NewStringUTF(env, retPtr); |
|
240 } |
|
241 |
|
242 JNIEXPORT jint JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_elf_1ndxscn |
|
243 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj) { |
|
244 jint secnum = SHN_UNDEF; |
|
245 jlong addr = getNativeAddress(env, ptrObj); |
|
246 if (addr != -1) { |
|
247 // Call libelf function |
|
248 secnum = elf_ndxscn((Elf_Scn*) addr); |
|
249 } else { |
|
250 fprintf(stderr, "Failed to get native address to call elf_ndxscn()\n"); |
|
251 } |
|
252 return secnum; |
|
253 } |
|
254 |
|
255 JNIEXPORT jobject JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_gelf_1newehdr |
|
256 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj, jint elfClass) { |
|
257 unsigned long int retPtr = 0; |
|
258 jlong addr = getNativeAddress(env, ptrObj); |
|
259 if (addr != -1) { |
|
260 // Call libelf function |
|
261 if ((retPtr = gelf_newehdr((Elf*) addr, elfClass)) == 0) { |
|
262 errx(EX_SOFTWARE, "gelf_newehdr() failed: %s.", elf_errmsg(-1)); |
|
263 } |
|
264 } else { |
|
265 fprintf(stderr, "Failed to get native address to call elf_newehdr()\n"); |
|
266 } |
|
267 return makePointerObject(env, (jlong) retPtr); |
|
268 } |
|
269 |
|
270 JNIEXPORT jobject JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_gelf_1newphdr |
|
271 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj, jint phnum) { |
|
272 unsigned long int retPtr = 0; |
|
273 jlong addr = getNativeAddress(env, ptrObj); |
|
274 if (addr != -1) { |
|
275 // Call libelf function |
|
276 if ((retPtr = gelf_newphdr((Elf*) addr, phnum)) == 0) { |
|
277 errx(EX_SOFTWARE, "gelf_newphdr() failed: %s.", elf_errmsg(-1)); |
|
278 } |
|
279 } else { |
|
280 fprintf(stderr, "Failed to get native address to call elf_newphdr()\n"); |
|
281 } |
|
282 return makePointerObject(env, (jlong) retPtr); |
|
283 } |
|
284 |
|
285 |
|
286 /* File operations */ |
|
287 |
|
288 JNIEXPORT jint JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_open_1rw |
|
289 (JNIEnv * env, jclass UNUSED(class), jstring jfileName) { |
|
290 int flags = O_RDWR | O_CREAT | O_TRUNC; |
|
291 int mode = 0666; |
|
292 int retVal; |
|
293 const char* cfileName = (*env)->GetStringUTFChars(env, jfileName, NULL); |
|
294 if (cfileName == NULL) { |
|
295 return -1; |
|
296 } |
|
297 retVal = open(cfileName, flags, mode); |
|
298 if (retVal < 0) { |
|
299 err(EX_NOINPUT, "open %s failed", cfileName); |
|
300 } |
|
301 (*env)->ReleaseStringUTFChars(env, jfileName, cfileName); |
|
302 |
|
303 return retVal; |
|
304 } |
|
305 |
|
306 JNIEXPORT jint JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_open__Ljava_lang_String_2I |
|
307 (JNIEnv * env, jclass UNUSED(class), jstring jfileName, jint flags) { |
|
308 int retVal; |
|
309 const char* cfileName = (*env)->GetStringUTFChars(env, jfileName, NULL); |
|
310 if (cfileName == NULL) { |
|
311 return -1; |
|
312 } |
|
313 retVal = open(cfileName, flags); |
|
314 if (retVal < 0) { |
|
315 err(EX_NOINPUT, "open %s failed", cfileName); |
|
316 } |
|
317 (*env)->ReleaseStringUTFChars(env, jfileName, cfileName); |
|
318 |
|
319 return retVal; |
|
320 } |
|
321 |
|
322 JNIEXPORT jint JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_open__Ljava_lang_String_2II |
|
323 (JNIEnv * env, jclass UNUSED(class), jstring jfileName, jint flags, jint mode) { |
|
324 int retVal; |
|
325 const char* cfileName = (*env)->GetStringUTFChars(env, jfileName, NULL); |
|
326 if (cfileName == NULL) { |
|
327 return -1; |
|
328 } |
|
329 retVal = open(cfileName, flags, mode); |
|
330 if (retVal < 0) { |
|
331 err(EX_NOINPUT, "open %s failed", cfileName); |
|
332 } |
|
333 (*env)->ReleaseStringUTFChars(env, jfileName, cfileName); |
|
334 |
|
335 return retVal; |
|
336 } |
|
337 |
|
338 |
|
339 JNIEXPORT jint JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_close |
|
340 (JNIEnv* UNUSED(env), jclass UNUSED(class), jint fd) { |
|
341 return close(fd); |
|
342 } |
|
343 |
|
344 /** |
|
345 * Miscellaneous ELF data structure peek-poke functions in |
|
346 * shim_functions.c. No corresponding .h file exists yet. |
|
347 * So each function needs to be declared as extern |
|
348 */ |
|
349 |
|
350 extern int size_of_Sym(int elfclass); |
|
351 extern int size_of_Rel(int elfclass); |
|
352 extern int size_of_Rela(int elfclass); |
|
353 |
|
354 extern void ehdr_set_data_encoding(void * ehdr, int val); |
|
355 extern void set_Ehdr_e_machine(int elfclass, void * structPtr, int val); |
|
356 extern void set_Ehdr_e_type(int elfclass, void * structPtr, int val); |
|
357 extern void set_Ehdr_e_version(int elfclass, void * structPtr, int val); |
|
358 extern void set_Ehdr_e_shstrndx(int elfclass, void * structPtr, int val); |
|
359 |
|
360 extern void phdr_set_type_self(int elfclass, void * ehdr, void * phdr); |
|
361 extern void phdr_set_type_self(int elfclass, void * ehdr, void * phdr); |
|
362 |
|
363 extern void set_Shdr_sh_name(int elfclass, void* structPtr, int val); |
|
364 extern void set_Shdr_sh_type(int elfclass, void* structPtr, int val); |
|
365 extern void set_Shdr_sh_flags(int elfclass, void* structPtr, int val); |
|
366 extern void set_Shdr_sh_entsize(int elfclass, void* structPtr, int val); |
|
367 extern void set_Shdr_sh_link(int elfclass, void* structPtr, int val); |
|
368 extern void set_Shdr_sh_info(int elfclass, void* structPtr, int val); |
|
369 |
|
370 extern void set_Data_d_align(void* structPtr, int val); |
|
371 extern void set_Data_d_off(void* structPtr, int val); |
|
372 extern void set_Data_d_buf(void* structPtr, void* val); |
|
373 extern void set_Data_d_type(void* structPtr, int val); |
|
374 extern void set_Data_d_size(void* structPtr, int val); |
|
375 extern void set_Data_d_version(void* structPtr, int val); |
|
376 |
|
377 extern void* create_sym_entry(int elfclass, int index, int type, int bind, |
|
378 int shndx, int size, int value); |
|
379 extern void * create_reloc_entry(int elfclass, int roffset, int symtabIdx, |
|
380 int relocType, int raddend, int reloca); |
|
381 |
|
382 JNIEXPORT jint JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_size_1of_1Sym |
|
383 (JNIEnv* UNUSED(env), jclass UNUSED(c), jint elfClass) { |
|
384 return size_of_Sym(elfClass); |
|
385 } |
|
386 |
|
387 JNIEXPORT jint JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_size_1of_1Rela |
|
388 (JNIEnv* UNUSED(env), jclass UNUSED(c), jint elfClass) { |
|
389 return size_of_Rela(elfClass); |
|
390 } |
|
391 |
|
392 JNIEXPORT jint JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_size_1of_1Rel |
|
393 (JNIEnv* UNUSED(env), jclass UNUSED(c), jint elfClass) { |
|
394 return size_of_Rel(elfClass); |
|
395 } |
|
396 |
|
397 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_ehdr_1set_1data_1encoding |
|
398 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj, jint val) { |
|
399 void* ehdr = (void*) getNativeAddress(env, ptrObj); |
|
400 ehdr_set_data_encoding(ehdr, val); |
|
401 } |
|
402 |
|
403 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Ehdr_1e_1machine |
|
404 (JNIEnv* env, jclass UNUSED(c), jint elfClass, jobject ptrObj, jint val) { |
|
405 void* ehdr = (void*) getNativeAddress(env, ptrObj); |
|
406 set_Ehdr_e_machine(elfClass, ehdr, val); |
|
407 } |
|
408 |
|
409 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Ehdr_1e_1type |
|
410 (JNIEnv* env, jclass UNUSED(c), jint elfClass, jobject ptrObj, jint val) { |
|
411 void* ehdr = (void*) getNativeAddress(env, ptrObj); |
|
412 set_Ehdr_e_type(elfClass, ehdr, val); |
|
413 } |
|
414 |
|
415 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Ehdr_1e_1version |
|
416 (JNIEnv* env, jclass UNUSED(c), jint elfClass, jobject ptrObj, jint val) { |
|
417 void* ehdr = (void*) getNativeAddress(env, ptrObj); |
|
418 set_Ehdr_e_version(elfClass, ehdr, val); |
|
419 } |
|
420 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Ehdr_1e_1shstrndx |
|
421 (JNIEnv* env, jclass UNUSED(c), jint elfClass, jobject ptrObj, jint val) { |
|
422 void* shdr = (void*) getNativeAddress(env, ptrObj); |
|
423 set_Ehdr_e_shstrndx(elfClass, shdr, val); |
|
424 } |
|
425 |
|
426 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_phdr_1set_1type_1self |
|
427 (JNIEnv* env, jclass UNUSED(c), jint elfClass, jobject ehdrPtr, jobject phdrPtr) { |
|
428 void* ehdr = (void*) getNativeAddress(env, ehdrPtr); |
|
429 void* phdr = (void*) getNativeAddress(env, phdrPtr); |
|
430 phdr_set_type_self(elfClass, ehdr, phdr); |
|
431 } |
|
432 |
|
433 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Shdr_1sh_1name |
|
434 (JNIEnv* env, jclass UNUSED(c), jint elfClass, jobject ptrObj, jint val) { |
|
435 void* shdr = (void*) getNativeAddress(env, ptrObj); |
|
436 set_Shdr_sh_name(elfClass, shdr, val); |
|
437 } |
|
438 |
|
439 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Shdr_1sh_1type |
|
440 (JNIEnv* env, jclass UNUSED(c), jint elfClass, jobject ptrObj, jint val) { |
|
441 void* shdr = (void*) getNativeAddress(env, ptrObj); |
|
442 set_Shdr_sh_type(elfClass, shdr, val); |
|
443 } |
|
444 |
|
445 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Shdr_1sh_1flags |
|
446 (JNIEnv* env, jclass UNUSED(c), jint elfClass, jobject ptrObj, jint val) { |
|
447 void* shdr = (void*) getNativeAddress(env, ptrObj); |
|
448 set_Shdr_sh_flags(elfClass, shdr, val); |
|
449 } |
|
450 |
|
451 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Shdr_1sh_1entsize |
|
452 (JNIEnv* env, jclass UNUSED(c), jint elfClass, jobject ptrObj, jint val) { |
|
453 void* shdr = (void*) getNativeAddress(env, ptrObj); |
|
454 set_Shdr_sh_entsize(elfClass, shdr, val); |
|
455 } |
|
456 |
|
457 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Shdr_1sh_1info |
|
458 (JNIEnv* env, jclass UNUSED(c), jint elfClass, jobject ptrObj, jint val) { |
|
459 void* shdr = (void*) getNativeAddress(env, ptrObj); |
|
460 set_Shdr_sh_info(elfClass, shdr, val); |
|
461 } |
|
462 |
|
463 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Shdr_1sh_1link |
|
464 (JNIEnv* env, jclass UNUSED(c), jint elfClass, jobject ptrObj, jint val) { |
|
465 void* shdr = (void*) getNativeAddress(env, ptrObj); |
|
466 set_Shdr_sh_link(elfClass, shdr, val); |
|
467 } |
|
468 |
|
469 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Data_1d_1align |
|
470 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj, jint val) { |
|
471 void* dptr = (void*) getNativeAddress(env, ptrObj); |
|
472 set_Data_d_align(dptr, val); |
|
473 } |
|
474 |
|
475 |
|
476 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Data_1d_1off |
|
477 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj, jint val) { |
|
478 void* dptr = (void*) getNativeAddress(env, ptrObj); |
|
479 set_Data_d_off(dptr, val); |
|
480 } |
|
481 |
|
482 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Data_1d_1buf |
|
483 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj, jobject bufPtr) { |
|
484 void* dptr = (void*) getNativeAddress(env, ptrObj); |
|
485 void* bptr = (void*) getNativeAddress(env, bufPtr); |
|
486 set_Data_d_buf(dptr, bptr); |
|
487 } |
|
488 |
|
489 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Data_1d_1type |
|
490 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj, jint val) { |
|
491 void* dptr = (void*) getNativeAddress(env, ptrObj); |
|
492 set_Data_d_type(dptr, val); |
|
493 } |
|
494 |
|
495 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Data_1d_1size |
|
496 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj, jint val) { |
|
497 void* dptr = (void*) getNativeAddress(env, ptrObj); |
|
498 set_Data_d_size(dptr, val); |
|
499 } |
|
500 |
|
501 JNIEXPORT void JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_set_1Data_1d_1version |
|
502 (JNIEnv* env, jclass UNUSED(c), jobject ptrObj, jint val) { |
|
503 void* dptr = (void*) getNativeAddress(env, ptrObj); |
|
504 set_Data_d_version(dptr, val); |
|
505 } |
|
506 |
|
507 JNIEXPORT jlong JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_create_1sym_1entry |
|
508 (JNIEnv* UNUSED(env), jclass UNUSED(c), jint elfClass, jint index, jint type, |
|
509 jint bind, jint shndx, jint size, jint value) { |
|
510 void * retVal = create_sym_entry(elfClass, index, type, bind, |
|
511 shndx, size, value); |
|
512 return (jlong)retVal; |
|
513 } |
|
514 |
|
515 JNIEXPORT jlong JNICALL Java_jdk_tools_jaotc_jnilibelf_JNILibELFAPI_create_1reloc_1entry |
|
516 (JNIEnv* UNUSED(env), jclass UNUSED(c), jint elfClass, jint roffset, |
|
517 jint symTabIdx, jint relocType, jint raddend, jint reloca) { |
|
518 void * retVal = create_reloc_entry(elfClass, roffset, symTabIdx, |
|
519 relocType, raddend, reloca); |
|
520 return (jlong)retVal; |
|
521 } |
|
522 |
|