* Compiling applications using cross compiler packs libc
@ 2008-05-12 9:12 Ramkumar J
2008-05-12 10:02 ` Marco Stornelli
2008-05-12 10:27 ` Alessandro Rubini
0 siblings, 2 replies; 4+ messages in thread
From: Ramkumar J @ 2008-05-12 9:12 UTC (permalink / raw)
To: linuxppc-embedded
[-- Attachment #1: Type: text/plain, Size: 1220 bytes --]
Hi All,
I am trying to execute a compiled simple stand-alone application (
TestApp_Memory.c compiled with gcc 4.1.0 cross compiler for ppc [ I have
installed this through crosstool on a Linux PC ] ) on the ML403 Board
instead of using the compiler-set provided by XPS. I tried many options (
like --static to gcc) to make the object file little as produced by the XPS
Compiler Set. I find that when static is provided, the glibc is also packed
up as a part of application though I never make any calls to the glibc
libraries. If I dont provide the --static, the gcc produces a code assuming
the library as shared and hence I get an interp section.
Is there any way to produce the code with only the application and NOT the
glibc ( As XPS compilers does). Am I missing out something. Is there any
specific flags. I find even nodefaultlib does not work.
For Eg: This is another example I tried
int main()
{
int a = 5;
int b = 10;
int c = 15;
c = a + b;
c += 12;
return 0;
}
With --static compilation, size is about 500K for the above code though the
useful content is too less. objdump reveals unneccessary calls to the libc.
Any suggestions would be helpful.
Thanks and Regards,
Ramkumar
[-- Attachment #2: Type: text/html, Size: 1415 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Compiling applications using cross compiler packs libc
2008-05-12 9:12 Compiling applications using cross compiler packs libc Ramkumar J
@ 2008-05-12 10:02 ` Marco Stornelli
2008-05-12 10:27 ` Alessandro Rubini
1 sibling, 0 replies; 4+ messages in thread
From: Marco Stornelli @ 2008-05-12 10:02 UTC (permalink / raw)
To: Ramkumar J; +Cc: linuxppc-embedded
Ramkumar J ha scritto:
> Hi All,
>
> I am trying to execute a compiled simple stand-alone application (
> TestApp_Memory.c compiled with gcc 4.1.0 cross compiler for ppc [ I have
> installed this through crosstool on a Linux PC ] ) on the ML403 Board
> instead of using the compiler-set provided by XPS. I tried many options (
> like --static to gcc) to make the object file little as produced by the XPS
> Compiler Set. I find that when static is provided, the glibc is also packed
> up as a part of application though I never make any calls to the glibc
> libraries. If I dont provide the --static, the gcc produces a code assuming
> the library as shared and hence I get an interp section.
> Is there any way to produce the code with only the application and NOT the
> glibc ( As XPS compilers does). Am I missing out something. Is there any
> specific flags. I find even nodefaultlib does not work.
>
> For Eg: This is another example I tried
>
> int main()
> {
> int a = 5;
> int b = 10;
> int c = 15;
>
> c = a + b;
>
> c += 12;
>
> return 0;
> }
>
> With --static compilation, size is about 500K for the above code though the
> useful content is too less. objdump reveals unneccessary calls to the libc.
> Any suggestions would be helpful.
>
> Thanks and Regards,
> Ramkumar
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Linuxppc-embedded mailing list
> Linuxppc-embedded@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-embedded
You shouldn't use --static but -Os to have a "little" program. With
static you include all the libraries in your application therefore you
have a bigger application. In addition libc are basic libraries so you
have to use it. If you have size problems you can use uclibc.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Compiling applications using cross compiler packs libc
2008-05-12 9:12 Compiling applications using cross compiler packs libc Ramkumar J
2008-05-12 10:02 ` Marco Stornelli
@ 2008-05-12 10:27 ` Alessandro Rubini
2008-05-14 5:57 ` David H. Lynch Jr.
1 sibling, 1 reply; 4+ messages in thread
From: Alessandro Rubini @ 2008-05-12 10:27 UTC (permalink / raw)
To: ramkumarj2000; +Cc: linuxppc-embedded
> the glibc is also packed
> up as a part of application though I never make any calls to the glibc
> libraries.
As already pointed out by Marco Stornelli, you shouldn't get concerned
about glibc as it's a standard library and you expect it to be part of
the target system (again, use uclibc if size is an issue).
If however you really want to build an application without library, you
should change the linker script. The kernel is not calling main() directly,
there is some initial setup involved, and this is where glibc (or uclibc)
is involved, even if you do no library calls yourself.
Look at a boot loader, or at the kernel, and then to proper
documentation, to find how to provide your own linker script to avoid
a library. But I doubt you really need it.
/alessandro
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Compiling applications using cross compiler packs libc
2008-05-12 10:27 ` Alessandro Rubini
@ 2008-05-14 5:57 ` David H. Lynch Jr.
0 siblings, 0 replies; 4+ messages in thread
From: David H. Lynch Jr. @ 2008-05-14 5:57 UTC (permalink / raw)
To: ramkumarj2000; +Cc: linuxppc-embedded
Alessandro Rubini wrote:
>> the glibc is also packed
>> up as a part of application though I never make any calls to the glibc
>> libraries.
>>
>
> If however you really want to build an application without library, you
> should change the linker script.
some or all of the following gcc flags might be useful if you are truly
compiling an OS independent very small application
-U__linux__
-nostdlib
-nostdinc
-mno-eabi
-fno-builtin
-nostartfiles
-nodefaultlibs
-nostdlib
Also as Alessandro pointed out you will likely need a link script.
--
Dave Lynch DLA Systems
Software Development: Embedded Linux
717.627.3770 dhlii@dlasys.net http://www.dlasys.net
fax: 1.253.369.9244 Cell: 1.717.587.7774
Over 25 years' experience in platforms, languages, and technologies too numerous to list.
"Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."
Albert Einstein
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-05-14 6:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-12 9:12 Compiling applications using cross compiler packs libc Ramkumar J
2008-05-12 10:02 ` Marco Stornelli
2008-05-12 10:27 ` Alessandro Rubini
2008-05-14 5:57 ` David H. Lynch Jr.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).