Cutting from nm command - Unix

This is a discussion on Cutting from nm command - Unix ; As a part of a linker step for an application we're building we need to use objcopy to hide the symbols which should be marked private (to avoid confusion with other libraries). For most platforms this has been a static ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Cutting from nm command

  1. Cutting from nm command

    As a part of a linker step for an application we're building we need to use
    objcopy to hide the symbols which should be marked private (to avoid
    confusion with other libraries).

    For most platforms this has been a static list which we've had in a
    textfile.
    However for hp-ux 11.11 there are a number of symbols starting with
    _GLOBAL__ which needs to be unmarked as hidden.

    Viewing the output from nm we get the following:

    bash-3.2# nm temp/hpux_hppa_ilp32/lmxrtw.o | grep _GLOBAL__

    _GLOBAL__D__Z30XMHAVHVMSAPHZKJRRGAOBYPACBAMKTP4FIL E| 33552|static|entry
    |$CODE$
    _GLOBAL__D___cxa_get_globals_fast| 336312|static|entry |$CODE$
    _GLOBAL__F_.._.._.._.._libstdc___v3_src_string_ins t.cc_35A49152_BB9F5F62|1073818500|static|data
    |$DATA$
    _GLOBAL__F__Z30XMHAVHVMSAPHZKJRRGAOBYPACBAMKTP4FIL E_74692525|1073786448|static|data
    |$DATA$
    _GLOBAL__F__ZN10__cxxabiv111__terminateEPFvvE_B1D5 CE00|1073831536|static|data
    |$DATA$
    ....

    In thise cases we would need to cut away the part starting from the first
    '|' and transform it into a single line as: -G symbol1 -G symbol2 -G etc. to
    satisfy the commandline of objcopy.
    Which command would be appropriate for cutting anyway anything from the
    first '|' char?

    Thanks.

    -- Henrik



  2. Re: Cutting from nm command

    "Henrik Goldman" writes:

    > Which command would be appropriate for cutting anyway anything from the
    > first '|' char?


    $ echo 'abc|def|ghi' | cut -d'|' -f1
    abc
    $

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

  3. Re: Cutting from nm command

    On 9 Dec, 21:41, "Henrik Goldman" wrote:
    > As a part of a linker step for an application we're building we need to use
    > objcopy to hide the symbols which should be marked private (to avoid
    > confusion with other libraries).



    Forgive me if this is a stupid question, or perhaps
    just really gnu-centric, but why not use
    __attribute__((visibility("hidden"))) ? Is
    that completely gnu specific?

  4. Re: Cutting from nm command

    William Pursell writes:

    > Forgive me if this is a stupid question, or perhaps
    > just really gnu-centric, but why not use
    > __attribute__((visibility("hidden"))) ? Is
    > that completely gnu specific?


    The whole __attribute__ business is completely GNU-specific, but
    that's not the problem, since Henrik is using g++.

    Rather, the problem is that 'hidden' (or any other) visibility
    is only supported on ELF platforms, and HP-UX 11.11 for PA-RISC
    doesn't use ELF objects in 32-bit mode.

    Cheers,
    --
    In order to understand recursion you must first understand recursion.
    Remove /-nsp/ for email.

+ Reply to Thread