gcc and strip

el-topo · 204

el-topo

  • Newbie
  • *
    • Posts: 5
    • Karma: +0/-0
on: January 29, 2020, 02:32:01 PM
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: 54
    • Karma: +1/-0
  • Hobby coder
Reply #1 on: January 30, 2020, 08:10:55 AM
That's a quirk with ABI v0.  That has been fixed in ABI v1.



mmartinka

  • Newbie
  • *
    • Posts: 22
    • Karma: +0/-0
Reply #2 on: January 30, 2020, 09: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: 5
    • Karma: +0/-0
Reply #3 on: January 31, 2020, 12:48:40 PM
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

  • Newbie
  • *
    • Posts: 39
    • Karma: +1/-0
Reply #4 on: February 01, 2020, 02:46:30 AM
Here's another alternative, that might help.
strip myprogram --strip-unneeded --remove-section .comment



el-topo

  • Newbie
  • *
    • Posts: 5
    • Karma: +0/-0
Reply #5 on: February 02, 2020, 10: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, 02:09:02 PM by el-topo »