Friday 15 July 2011

c - How to get address of function generated by MACRO inside OPENSSL -



c - How to get address of function generated by MACRO inside OPENSSL -

i trying find address of 2 functions defined within openssl. 1 defined normal function , defined macro function.

here details of 2 functions :

inside bn_mul.c file,

#ifdef bn_recursion //macro function void bn_mul_recursive(bn_ulong *r, bn_ulong *a, bn_ulong *b, int n2, int dna, int dnb, bn_ulong *t) #endif // bn_recursion //normal function int bn_mul(bignum *r, const bignum *a, const bignum *b, bn_ctx *ctx) { }

inside bn.h header file,

#define bn_recursion int bn_mul(bignum *r, const bignum *a, const bignum *b, bn_ctx *ctx);

when seek find address of bn_mul function , bn_mul_recursive macro function , trying utilize &bn_mul , &bn_mul_recursive respectively. i getting error bn_mul_recursive macro function. have used -fpic while building openssl. used next command compile,

gcc address_macro2.c -lcrypto

#include<stdio.h> #include <openssl/bn.h> int main() { printf("address of bn_mul =%p\n",&bn_mul); printf("address of bn_mul_recursive=%p\n",&bn_mul_recursive); homecoming 0; } error: address_macro2.c:13:44: error: ‘bn_mul_recursive’ undeclared (first utilize in function)

i using gcc under linux. how resolve error ?

i can't utilize -i/path_to_file_bn_mul.c nullified effect of -fpic option.

any clue or link great help. in advance.

finally , resolved above problem.

the error shows, programme unable find definition of bn_mul_recursive function in scope of address_macro2.c program.

so add together next statement

extern void bn_mul_recursive(bn_ulong *, bn_ulong *, bn_ulong *, int , int , int , bn_ulong *);

now right programme is,

#include<stdio.h> #include <openssl/bn.h> extern void bn_mul_recursive(bn_ulong *, bn_ulong *, bn_ulong *, int , int , int , bn_ulong *); int main() { printf("address of bn_mul =%p\n",&bn_mul); printf("address of bn_mul_recursive=%p\n",&bn_mul_recursive); homecoming 0; }

output :

address of bn_mul =0x8048430 address of bn_mul_recursive=0x8048460

c linux macros

No comments:

Post a Comment