[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] '-e' parameter in gcc
Hi,
On tiistai 25 tammikuu 2011, Miro Kropáček wrote:
> One project I'm playing with uses configure in this way to check for
> default output (stripped):
>
> m68k-atari-mint-gcc -nostdlib -e main conftest.c
>From GCC manual page:
-nostdlib
Do not use the standard system startup files or libraries when
linking. No startup files and only the libraries you specify
will be passed to the linker.
...
In most cases, you need libgcc.a even when you want to avoid
other standard libraries. In other words, when you specify
-nostdlib or -nodefaultlibs you should usually specify -lgcc as
well. This ensures that you have no unresolved references to
internal GCC library subroutines. (For example, __main, used to
ensure C++ constructors will be called.)
>From ld manual page:
-e entry
--entry=entry
Use entry as the explicit symbol for beginning execution of your
program, rather than the default entry point. If there is no
symbol named entry, the linker will try to parse entry as a
number, and use that as the entry address (the number will be
interpreted in base 10; you may use a leading 0x for base 16, or
a leading 0 for base 8).
> conftest.c is classic dummy file with main() defined. It fails with:
To check a bit more how this works on Linux, I tried a program that
doesn't have even main():
int True(void) { return 1; }
It compiles fine with:
gcc -nostdlib -e True true.c
Only if I try to compile it with:
gcc -nostdlib -e main true.c
Then it gives the mistmatch warning:
/usr/bin/ld: warning: cannot find entry symbol main; defaulting to
00000000080480b8
> /home/mikro/gnu-tools/lib/gcc/m68k-atari-mint/4.5.1/../../../../m68k-
atari-mint/bin/ld: warning: cannot find entry symbol main; defaulting to
> 000000e4
>
> /tmp/cc4HfuQ9.o:/tmp/cc4HfuQ9.o:(.text+0x6): undefined reference to
> `___main'
> collect2: ld returned 1 exit status
Sp... neither of these warnings should be generarated for the program;
main() is there so it should be found and because -nostdlib was used, no
references to __main should be required?
I guess Atari gcc and linker seem to have different interpretation on symbol
naming, at least in the case of "-e" option...?
> what configure interprets as inability to create executable files.
> However, on Linux, it works flawesly (creates a.out but of course, it
> crashes when executed, but that's not the point here).
>
> What causes it and how to solve it? Should I report it as bad practice
> for configure script to authors? (I don't know why they do it in this
> way, it's a system library, so maybe it's part of generic
> CFLAGS/LDFLAGS).
- Eero