Find the answer to your Linux question:
Results 1 to 2 of 2
Hello all, I am trying symbol hiding in GCC version 4.1, but it seems like i am not doing something right . Please find here in my example /* libhello.c*/ ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2007
    Posts
    3

    Symbol Hiding


    Hello all,

    I am trying symbol hiding in GCC version 4.1, but it seems like i am
    not doing something right .

    Please find here in my example

    /* libhello.c*/
    int sizeOfLong()
    {
    return sizeof(long);
    }

    void hello(void) {

    printf("size of a short is %d\n", sizeOfInt());
    printf("Hello, library world.\n");

    }

    /* libhello.h - demonstrate library use. */
    #define EXPORT __attribute__((visibility("default")))
    EXPORT void hello(void);
    int sizeOfInt();

    now i compile using the following commands:

    gcc -fPIC -fvisibility=hidden -Wall -g -c libhello.c
    gcc -g -shared -Wl,-soname,libhello.so.0 \
    -o libhello.so.0.0 libhello.o -lc

    do nm libhello.so

    I find both functions hello and sizeOfInt() in it why?

    Question 2:

    What is the difference between strip and symbol hiding.

    Thanks

    Newbei

  2. #2
    Linux User cyberinstru's Avatar
    Join Date
    Jan 2007
    Location
    India
    Posts
    362
    Use -s option to hide symbols.

    Code:
    gcc -s -g -shared -Wl,-soname,libhello.so.0 -o libhello.so.0.0 libhello.o -lc
    ---------------------------------
    Registered Linux User #440311
    HI2ARUN _AT_ GMAIL _DOT_ COM
    ---------------------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •