LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-04-2009, 04:41 PM   #1
technomeister
Member
 
Registered: Oct 2005
Distribution: Slackware loved and lost, Ubuntu current.
Posts: 34

Rep: Reputation: 15
shared library packer?


Does such a thing exist for shared objects in similar fasion to an executable packer?
 
Old 10-05-2009, 12:06 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by technomeister View Post
Does such a thing exist for shared objects in similar fasion to an executable packer?
Why/what for one needs a packer ?
 
Old 10-05-2009, 01:50 PM   #3
technomeister
Member
 
Registered: Oct 2005
Distribution: Slackware loved and lost, Ubuntu current.
Posts: 34

Original Poster
Rep: Reputation: 15
Only for the filesize... I'm working on a library that I have to frequently upload to a server to test. Zip achieves a compression ratio of around 75%, which is impressive, but it got me wondering if there's any specially targetted tool for the job, like there is for executables.

It'd save me having to zip / unzip every time I upload it (and would probably yield an even greater ratio than zip)
 
Old 10-05-2009, 02:19 PM   #4
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
maybe http://upx.sourceforge.net/ but its a stretch
 
Old 10-05-2009, 02:21 PM   #5
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339

Rep: Reputation: 231Reputation: 231Reputation: 231
WTF? forum bug it says it says if you opted to post a poll with this topic you will be redirected there or to that effect
 
Old 10-05-2009, 02:45 PM   #6
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
You should also consider the -Os gcc option, and of course stripping debug symbols and the symbol table. Assuming you've already done that, how exactly do you load a compressed shared library? As far as I know, ld.so will mmap the appropriate shared libraries at run-time. You might be able to hack it and make it bunzip, also, which would allow you to bzip2 the libraries.
Kevin Barry
 
Old 10-05-2009, 02:53 PM   #7
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by technomeister View Post
Only for the filesize... I'm working on a library that I have to frequently upload to a server to test. Zip achieves a compression ratio of around 75%, which is impressive, but it got me wondering if there's any specially targetted tool for the job, like there is for executables.

It'd save me having to zip / unzip every time I upload it (and would probably yield an even greater ratio than zip)
???

Under UNIX-like systems 'tar' and/or its better incarnation GNU tar exist.

Under UNIX-like systems 'gzip', 'bzip2', 'p7zip', 'zip' and other various compressors (including various LZMA ones) exist.

'tar' can call 'gzip' and 'bzip2' through 'z' and 'j' command line switches; I think that latest 'tar' versions know something about LZMA too.

'tar' can pack the whole directory.

'tar' can output to STDOUT while the compressors can take data from STDIN, so 'tar' can be combined with any of the above compressors.

So, why/what a specific application is needed ?

If you want one tool - write a shell alias or a script which combines/aggregates what is necessary - the amount of lines will be probably more than an order of magnitude less than in this post.
 
Old 10-05-2009, 03:05 PM   #8
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Unfortunately, upx will not work to compress shared libs. You can always use xz, bzip2 or whatever.

I was hoping that you were going to ask about be able to use compressed shared libs to run programs -exactly since upx doesn't work. Long ago, I saw a hackish way to do it by renaming and compressing the lib with whatever and then creating a wrapper with the original name which would then unpack and execute the real lib when needed.
 
Old 10-05-2009, 06:08 PM   #9
technomeister
Member
 
Registered: Oct 2005
Distribution: Slackware loved and lost, Ubuntu current.
Posts: 34

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by gnashley View Post
I was hoping that you were going to ask about be able to use compressed shared libs to run programs -exactly since upx doesn't work. Long ago, I saw a hackish way to do it by renaming and compressing the lib with whatever and then creating a wrapper with the original name which would then unpack and execute the real lib when needed.
Quote:
Originally Posted by ta0kira View Post
Assuming you've already done that, how exactly do you load a compressed shared library? As far as I know, ld.so will mmap the appropriate shared libraries at run-time. You might be able to hack it and make it bunzip, also, which would allow you to bzip2 the libraries.
Kevin Barry
That's the sort of thing I was after. I'm surprised there aren't any common solutions out there - not sure I want to try implementing it myself, however...

Quote:
Originally Posted by ta0kira View Post
You should also consider the -Os gcc option, and of course stripping debug symbols and the symbol table.
Aha. The -s option to remove the symbol table helps me a lot (80% filesize reduction).

That (and having found the ssh compression options for sFTP uploads) should do fine for now...
 
Old 10-05-2009, 07:04 PM   #10
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by technomeister View Post
...
I'm surprised there aren't any common solutions out there - not sure I want to try implementing it myself, however...
...

Already mentioned 'upx' does that:


http://linux.die.net/man/1/upx :

Quote:
General benefits:

- UPX can compress all executables, be it AOUT, ELF, libc4, libc5,
libc6, Shell/Perl/Python/... scripts, standalone Java .class
binaries, or whatever...
All scripts and programs will work just as before.

- Compressed programs are completely self-contained. No need for
any external program.
 
Old 10-06-2009, 12:48 AM   #11
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
"Already mentioned 'upx' does that:" but not shared libs. Just try it and you'll see that it refuses to do it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shared library : libfg.so: cannot open shared object file error 40 x_gaurav Programming 2 06-28-2009 06:29 AM
ldd reports shared library missing, but library exists on disk athv_gr Linux - Newbie 7 05-13-2009 12:31 PM
gcc link shared library against another shared library qcp Linux - Newbie 1 07-25-2008 11:15 AM
LINUX - linking archive (static library) with shared (dynamic) library gurkama Programming 5 03-04-2007 11:11 PM
howto compile bin with my library using all-static and shared linked standart library stpg Programming 4 06-29-2004 04:20 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration