gcc and strip

el-topo · 1746

el-topo

  • Newbie
  • *
    • Posts: 8
    • Karma: +1/-0
on: January 29, 2020, 07:32:01 AM
Hi folks!

I just installed Icaros Desktop on an i386 native machine and started to play around with gcc compiling "Hello World". I'm used to use the strip program to reduce the size of my binaries when I compile on Linux but when I tried it in AROS I get an error saying that there's not enough memory. The binary worked fine before stripping it (and with the -s option to gcc) so it seems strip removes something that's essential for the binary to run. Any idea what's up and if there's any remedy for this?



Samurai_Crow

  • Junior Member
  • **
    • Posts: 88
    • Karma: +32/-0
  • Hobby coder
Reply #1 on: January 30, 2020, 01:10:55 AM
That's a quirk with ABI v0.  That has been fixed in ABI v1.



mmartinka

  • Newbie
  • *
    • Posts: 48
    • Karma: +4/-0
Reply #2 on: January 30, 2020, 02:36:53 AM
Options "-s" removed all symbol and relocation information, then it cannot work. You try the options "-S" remove all symbols not needed by relocations.



el-topo

  • Newbie
  • *
    • Posts: 8
    • Karma: +1/-0
Reply #3 on: January 31, 2020, 05:48:40 AM
That's a quirk with ABI v0.  That has been fixed in ABI v1.

Aha, that explains it. A problem that will pass with time then :)



cavemann

  • Junior Member
  • **
    • Posts: 78
    • Karma: +86/-0
Reply #4 on: January 31, 2020, 07:46:30 PM
Here's another alternative, that might help.
strip myprogram --strip-unneeded --remove-section .comment



el-topo

  • Newbie
  • *
    • Posts: 8
    • Karma: +1/-0
Reply #5 on: February 02, 2020, 03:58:43 AM
Here's another alternative, that might help.
strip myprogram --strip-unneeded --remove-section .comment

Yes it does! Many thanks for posting this solution. Here is a comparison on the size of some hello world compiles:

Code: [Select]
test-stripped               7332 ---rwed Today       10:56:29
test-s                      7720 ---rwed Today       10:54:31
test-vanilla                9279 ---rwed Today       10:54:17

test-s is what you get using gcc -s. With such a small program there's not a huge difference, but I suppose the benefit will be much bigger as the source code grows.
« Last Edit: February 03, 2020, 07:09:02 AM by el-topo »