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

2008-04-23 Thread [EMAIL PROTECTED]



Brian Dessent wrote:

[EMAIL PROTECTED] wrote:

  

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.



As I understand it, the -fleading-underscore flag is only useful to add
a leading underscore for targets that do not have a leading underscore,
like linux.  It won't accomplish anything on one that already has it,
like PE.
  
You may be right. But then this is strange for me. I would guess that 
either -fleading-underscore or -fno-leading-underscore do something, but 
not both doing nothing. So if a target does have a leading underscore 
and then -fleading-underscore does nothing on it (according to what you 
say), then I would expect -fno-leading-underscore removing the underscore.



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.



There is absolutely no way that you can use an object compiled for Linux
with Cygwin.  The fact that symbols don't have a leading underscore is
trivial compared to the massive differences between ELF and PE formats. 
There is just no chance of this working even if you solved the

underscore issue.
  
I suspected this, but I was not sure. I do not know what is ELF and 
PE... I though about trying since I have Windows apps that work on 
Cygwin, but possibly they are much more similar.


Thanks a lot.

Santiago



Brian
  


--
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/



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

2008-04-23 Thread Brian Dessent
[EMAIL PROTECTED] wrote:

 You may be right. But then this is strange for me. I would guess that
 either -fleading-underscore or -fno-leading-underscore do something, but
 not both doing nothing. So if a target does have a leading underscore
 and then -fleading-underscore does nothing on it (according to what you
 say), then I would expect -fno-leading-underscore removing the underscore.

Adding an extra underscore on a platform that doesn't have one isn't
doing anything that you couldn't equivalently accomplish at the source
level, so it's not really violating any ABIs.  However, removing the
underscore when the platform spec says that all symbols must have a
leading underscore prepended would violate the ABI, and there is no
way[1] to achieve the equivalent thing at the source level so this is a
much more dangerous proposition.

That is the intent of the switch; it is not designed for what you're
trying to make it do.

 I suspected this, but I was not sure. I do not know what is ELF and
 PE... I though about trying since I have Windows apps that work on
 Cygwin, but possibly they are much more similar.

I think you are confused about what Cygwin is.  It is not a binary
emulator of any kind, it is a Win32 library just like any other DLL. 
All Cygwin apps are standard Win32 executables/libraries, there is no
difference as far as the operating system is concerned.

The reason you cannot use an object compiled with a Linux compiler is
because Linux uses an entirely different binary format and ABI.  Even
though they may run on the same identical hardware, the details of how
things work at the assembler and linker level are significantly
different.  The fact that it's gcc on both sides doesn't change
anything, because gcc's behavior is determined entirely by the target it
was configured for; two gccs of different targets are essentially two
totally different compilers.

Brian

[1] well technically it's possible using __asm__() but that's an
extension and not standard C.

--
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/



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

2008-04-23 Thread Eric Blake

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to [EMAIL PROTECTED] on 4/23/2008 8:27 AM:
| As I understand it, the -fleading-underscore flag is only useful to add
| a leading underscore for targets that do not have a leading underscore,
| like linux.  It won't accomplish anything on one that already has it,
| like PE.
|
| You may be right. But then this is strange for me. I would guess that
| either -fleading-underscore or -fno-leading-underscore do something, but
| not both doing nothing.

I look at it this way: -fleading-underscore adds an underscore on
platforms where it is not necessary (and is a no-op on platforms where
leading underscore is already required); -fno-leading-underscore undoes
the effect of an earlier -fleading-underscore (removes the underscore
where possible, and is a no-op on platforms like cygwin where it is not
possible).

- --
Don't work too hard, make some time for fun as well!

Eric Blake [EMAIL PROTECTED]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgP/nsACgkQ84KuGfSFAYCnXgCePRD9+U8AZusRmgRqWeBjhtmK
sEEAn3hHttMrUCi21Ch13oC7aL5fZJL5
=pizv
-END PGP SIGNATURE-

--
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/



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

2008-04-22 Thread san . temporal
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 [EMAIL PROTECTED]
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 [EMAIL PROTECTED]
 00402000 A __data_end__
00402000 A __data_start__
 A __dll__
00405000 A __end__
0200 A __file_alignment__
00403010 B __fmode
00404000 I __head_cygwin1_dll
00404014 I __head_libkernel32_a
 0040 A __image_base__
004040a4 I [EMAIL PROTECTED]
00404078 I __impmain
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

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

2008-04-22 Thread Brian Dessent
[EMAIL PROTECTED] wrote:

 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.

As I understand it, the -fleading-underscore flag is only useful to add
a leading underscore for targets that do not have a leading underscore,
like linux.  It won't accomplish anything on one that already has it,
like PE.

 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.

There is absolutely no way that you can use an object compiled for Linux
with Cygwin.  The fact that symbols don't have a leading underscore is
trivial compared to the massive differences between ELF and PE formats. 
There is just no chance of this working even if you solved the
underscore issue.

Brian

--
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/