Results 1 to 5 of 5

Thread: Bit off topic - but is anyone good with GCC under Linux ?

  1. #1
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,193
    Blog Entries
    8

    Default Bit off topic - but is anyone good with GCC under Linux ?

    I'm porting my free dice app to linux and its all going well and its working pretty good but the binary file has some issues with it. I have a few queries that no amount of searching the net seems to be able to answer. It about linking, linker sections, and binary strings & stripping so its not a light topic of questions. If anyone who has used GCC quite a lot would like to give me a few hints on the GCC flags then I would be much appreciated. Maybe I need a linux forum but you guys have been so knowledgeable on this forum on a number of tech topics that I thought Id start here.

    Prob best to PM me or I can post but its well off topic.
    Thx in advance.

  2. #2
    Guild Novice
    Join Date
    Feb 2008
    Location
    St Louis, MO, USA
    Posts
    24

    Default

    I'm going to suggest posting. That way, if there's anyone else around, we can join forces.

    Could you post the compiler output?

  3. #3
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,193
    Blog Entries
    8

    Default

    The compiler output is clean and the app works just great. My issue is that the binary is very large and I have been reading around that subject and switching on lots of flags and trying various combinations to reduce it. More at issue tho is that when I look at the binary there are loads of strings in it. Not just the strings that are supposed to be there but loads that are clearly not sensible. For a start loads of my function names and even the source filenames are built into the binary result.

    First of all this is without the -g debugging option on. I can also use -g0 in case anyways and its still the same. I have used Strip Dice.exe and with options of -s or -X and some more. I have compiled with the -s option for the object files and linkage. Then there is the -Os optimize for size and the discard c_sections. Then I tried the visibility flags. I am using gcc V4.4 which I think is the last maintained or stable version. Maybe I should try a 4.5 but anyways, if I set the visibility as hidden then the strings are still there.

    Also, looking at other apps on my ubuntu box - like some of the games etc, I can see the source file names and function names and class names in those as well. Is this just a 'feature' of using gcc and would I need to actively obfuscate names before compilation in order to avoid this ?

    Just to be clear, I am using a load of shared libs but none of them are mine - stuff like OpenGL, SDL, StdC etc. All my code is non library stuff. If I could I would compile it all static but I am told also that under linux this is hard to do since the libgcc and libc interact with the kernel in version specific ways that almost require you to link to those shared.

    So yeah, bit of an odd question here but anyone got advice or links to posts about that ?

  4. #4
    Guild Novice
    Join Date
    Feb 2008
    Location
    St Louis, MO, USA
    Posts
    24

    Default

    My first thought is do you really need to worry about this? Seems that you have two concerns. The first is executable size. The second is the exposure of filenames and function names.

    As for file size, disk space is cheap, and executables are paged into memory, so it doesn't matter if it's big. Are you trying to fit the executable into some specific size?

    On the information exposure, are you using C++ with anything virtual? I seem to recall that requires more information to be stored in the executable to work. Otherwise, static linking would probably improve stuff, but that would increase the size of your executables.

    I haven't had any experience with this, since my employers generally just haven't worried about it. I'd suggest checking Stack Overflow and asking there. Here's a previous question on this topic: http://stackoverflow.com/questions/2...iled-binary-so

  5. #5
    Administrator Redrobes's Avatar
    Join Date
    Dec 2007
    Location
    England
    Posts
    7,193
    Blog Entries
    8

    Default

    Thanks, and yes your right its more about the 2nd issue than first tho I want to run this on a particular small embedded board with limited RAM. The limit for the RAM is still a lot more than the app tho so its no real biggie.

    I saw that stack overflow post which is what prompted me to try the hidden visibility. This visibility thing is more to do with whether functions in a shared library are visible to link to. In windows you need to declare them visible with an 'export'. It seems in gcc that its by default mostly visible and you need to hide the ones you don't want people to be able to link to. But all of that is aside because its for making a shared lib but mine is an app which is self contained except for the shared libs it uses. A compiler (well linker) should attach all of the required loose ends together and then remove all those unused bits and then clean up the link info in the binary but gcc seems to be leaving a lot of cruft still in the binary. Personally I don't think there is a solution to this but maybe I am wrong. People who release non open source stuff for linux must have come across this but they might be using a different compiler and linker.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •