This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fwd: gcc does not honor -fno-leading-underscore flag?


Hi,

I have been scratching my head for a while... to no avail. I have
compiled a simple source file with and without -fno-leading-underscore
flag, and the objects generated seem to have exactly the same names
for all symbols, always having a leading underscore.

What I do:

1- Compile the source underscores.c (see below), with two different
command lines

$ gcc -g -g3 -Wall -Wextra -Wunused -Wuninitialized -Wfloat-equal
-Wundef -Wshadow underscores.c -o underscores.exe

and

$ gcc -g -g3 -Wall -Wextra -Wunused -Wuninitialized -Wfloat-equal
-Wundef -Wshadow underscores.c -o underscores.exe
-fno-leading-underscore

2- Obtain the symbols in each of the objects generated.

3- Diff them.

The result is that there are no differences. The complete list of
symbols is shown below. It is worth noting that the function f1
defined in underscores.c has _f1 as its symbol name.

I do not know how to get rid of the leading underscores in Cygwin. I
have other sources compiled in Linux, and they do not have a leading
underscore added.

Now my problem is that I have a library with symbol names without a
leading underscore. Although the library is for Linux (I do not have a
version specific for Cygwin, which would be the ideal solution, and I
do not think that I could get it; I don't have the sources), I expect
it to work under Cygwin (or at least give it a try), if only I could
get my objects to link with its symbols. Even if I am trying to mix
objects for different platforms, I guess that there should be a chance
to do it by appropriate configuration. The flag
-fno-leading-underscore seemed to be the answer, but it did not work
for me.

Any hints?

Thanks a lot.

-----------------------------------  output of $ nm underscores.exe
-------------------------------------------

00403020 b .bss
00403000 b .bss
00403010 b .bss
00403020 b .bss
 00403020 b .bss
00403020 b .bss
00403010 b .bss
00403020 b .bss
00403020 b .bss
00403020 b .bss
00403020 b .bss
00403010 b .bss
00403020 b .bss
00403010 b .bss
         U .data
         U .data
          U .data
         U .data
         U .data
         U .data
         U .data
         U .data
         U .data
         U .data
         U .data
         U .data
         U .data
         U .data
 00404014 i .idata$2
00404000 i .idata$2
0040406c i .idata$4
00404064 i .idata$4
0040403c i .idata$4
00404040 i .idata$4
00404058 i .idata$4
0040405c i .idata$4
00404050 i .idata$4
00404068 i .idata$4
 00404044 i .idata$4
0040404c i .idata$4
00404048 i .idata$4
00404060 i .idata$4
00404054 i .idata$4
00404070 i .idata$4
00404098 i .idata$5
0040409c i .idata$5
004040a4 i .idata$5
00404088 i .idata$5
 00404074 i .idata$5
00404080 i .idata$5
00404094 i .idata$5
004040a8 i .idata$5
0040407c i .idata$5
0040408c i .idata$5
00404078 i .idata$5
00404084 i .idata$5
004040a0 i .idata$5
00404090 i .idata$5
 00404130 i .idata$6
004040ac i .idata$6
004040d4 i .idata$6
00404104 i .idata$6
004040c8 i .idata$6
004040b8 i .idata$6
0040410c i .idata$6
00404124 i .idata$6
004040e8 i .idata$6
00404118 i .idata$6
 0040415c i .idata$7
00404168 i .idata$7
00404144 i .idata$7
00404160 i .idata$7
00404154 i .idata$7
00404148 i .idata$7
0040414c i .idata$7
00404164 i .idata$7
00404158 i .idata$7
00404178 i .idata$7
 00404150 i .idata$7
00404174 i .idata$7
00402000 r .rdata
00405000 N .stab
004013b8 t .text
00401390 t .text
00401350 t .text
00401340 t .text
004013a0 t .text
00401000 t .text
00401330 t .text
 00401320 t .text
004012c0 t .text
004013b0 t .text
004012c0 t .text
004012b0 t .text
00401160 t .text
00401150 t .text
00401140 t .text
004010e0 t .text
004010b0 t .text
004013b8 t .text
00401380 t .text
 004013c0 t .text
00401360 t .text
00401050 t .text
00401370 t .text
004013b0 T _GetModuleHandleA@4
00401000 T _WinMainCRTStartup
004013c0 T __CTOR_LIST__
004013c8 T __DTOR_LIST__
00402020 R __RUNTIME_PSEUDO_RELOC_LIST_END__
 00402020 R __RUNTIME_PSEUDO_RELOC_LIST__
004013c0 T ___CTOR_LIST__
004013c8 T ___DTOR_LIST__
00402020 R ___RUNTIME_PSEUDO_RELOC_LIST_END__
00402020 R ___RUNTIME_PSEUDO_RELOC_LIST__
004010b0 T ___chkstk
00405000 A ___crt_xc_end__
 00405000 A ___crt_xc_start__
00405000 A ___crt_xi_end__
00405000 A ___crt_xi_start__
00405000 A ___crt_xl_start__
00405000 A ___crt_xp_end__
00405000 A ___crt_xp_start__
00405000 A ___crt_xt_end__
00405000 A ___crt_xt_start__
 00403000 B ___cygwin_crt0_bp
00401140 T ___main
00405000 A ___tls_end__
00405000 A ___tls_start__
004010b0 T __alloca
00403040 B __bss_end__
00403000 B __bss_start__
00401160 T __cygwin_crt0_common@8
 00402000 A __data_end__
00402000 A __data_start__
00000000 A __dll__
00405000 A __end__
00000200 A __file_alignment__
00403010 B __fmode
00404000 I __head_cygwin1_dll
00404014 I __head_libkernel32_a
 00400000 A __image_base__
004040a4 I __imp__GetModuleHandleA@4
00404078 I __imp____main
0040407c I __imp___impure_ptr
00404080 I __imp__calloc
00404084 I __imp__cygwin_internal
00404088 I __imp__dll_crt0__FP11per_process
 0040408c I __imp__free
00404090 I __imp__malloc
00404094 I __imp__printf
00404098 I __imp__realloc
00404178 I __libkernel32_a_iname
00000000 A __loader_flags__
00000001 A __major_image_version__
00000004 A __major_os_version__
 00000004 A __major_subsystem_version__
00000000 A __minor_image_version__
00000000 A __minor_os_version__
00000000 A __minor_subsystem_version__
004040b8 I __nm___impure_ptr
004012f0 T __pei386_runtime_relocator
 00001000 A __section_alignment__
00001000 A __size_of_heap_commit__
00100000 A __size_of_heap_reserve__
00001000 A __size_of_stack_commit__
00200000 A __size_of_stack_reserve__
00000003 A __subsystem__
00401320 T _calloc
 00404168 I _cygwin1_dll_iname
004010e0 T _cygwin_crt0
004013a0 T _cygwin_internal
00401390 T _cygwin_premain0
00401380 T _cygwin_premain1
00401370 T _cygwin_premain2
00401360 T _cygwin_premain3
004012b0 T _dll_crt0__FP11per_process
 004012c0 T _do_pseudo_reloc
00403014 B _environ
004010a3 T _f1
00401340 T _free
00401050 T _main
00401000 T _mainCRTStartup
00401350 T _malloc
00401150 T _printf
00401330 T _realloc
004010cd t done
 004040a4 i fthunk
0040406c i hname
004010b6 t probe

-------------------------  source underscores.c
--------------------------------

#include <stdio.h>

int f1( const int a );

int main( void )
 {
    int b = 2;
    printf( "Calling f1. Result = %d\n", f1( b ) );
    return 1;
}

int f1( const int a )
{
  return 1;
}

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]