Solved

shared library downsize by libraryopt on sourceforge.net

Posted on 2004-09-08
11
309 Views
Last Modified: 2008-01-09
How to use libraryopt to downsize shared library, uClibc, with respect to embedded target file system.  thanks
http://sourceforge.net/projects/libraryopt
0
Comment
Question by:lightlu
  • 5
  • 3
11 Comments
 
LVL 45

Expert Comment

by:sunnycoder
Comment Utility
The Library Optimizer is invoked as follows:

libopt [-s] [ -d <destroot> ] <targetroot>

<targetroot> should be the base directory of the full target filesystem tree. It must include all the executable programs and shared libraries that will be present on the target.

The optional <destroot> specifies an alternate directory where the optimized libraries will be placed. If <destroot> is not specified, <targetroot> will be used as the destination, overwriting the original target libraries.

The optional argument "-s" should be specified if the optimized libraries should be stripped. This can greatly reduce the size of the optimized libraries, but reduces the amount of debugging information available.
http://libraryopt.sourceforge.net/use.html

Configuring the Library Optimizer Tool
http://libraryopt.sourceforge.net/config.html
0
 

Author Comment

by:lightlu
Comment Utility
Is there a step by step example?  I give a very simple dynamic shared library named liball.so which composed of lib1.o and lib2.o, with a program which uses function belongs to lib1.o only.  I create path, index and build file according to document in target/usr/lib/optinfo/liball, but the result of libopt is null.  thanks very much.
0
 
LVL 45

Expert Comment

by:sunnycoder
Comment Utility
What was the command line you used ?

Are you sure that functions in lib1.o do not call functions in lib2.o ... Also make sure that there are no other programs in the directory which use lib2.o, directly or indirectly
0
 

Author Comment

by:lightlu
Comment Utility
Sorry, I had tried it out.  And I think the difficulity to use libraryopt is to prepare the build script for it.  While deling with embedded system, the cross toolchain envirement increase the usage complexity.  Is there any image downsize real case?  What is the downsize percentage?  Thanks
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 45

Expert Comment

by:sunnycoder
Comment Utility
> Is there any image downsize real case?  What is the downsize percentage?
I have not tried it or any other tool for downsizing

use strip(1) to remove the symbols. The strip(1) command gives you a good deal of control over what symbols to eliminate; see its documentation for details.
0
 

Author Comment

by:lightlu
Comment Utility
Yes, strip is good tool for retrieve binary symbol information.  But only the raw strip usage to deliver commercial product is not realistic.  The minimun object for libraryopt for downsizing shared library is *.o file.  However uclibc.so is built from libc.a which composed of those *.o choosen from menuconfig.  I am trying give a build script which build libuclibc.so from all *.o directly.
0
 
LVL 1

Expert Comment

by:bsnh99
Comment Utility
Does your index file contain the entries you expect?
What does your build file look like?
What platform are you building for?
What toolchain are you using?

Post these and I'll try to help.
0
 

Author Comment

by:lightlu
Comment Utility
I found that I failed to optimize my simplest example on i386 platform.  This example includes lib1.c, lib2.c and go.c as following.
lib1.c: show1() {printf("this is show1\n");}
lib2.c: show2() {printf("this is show2\n");}
go.c: main() { show1(); }
The output of libindex only contains two lines, O lib1.o and O lib2.o, which was produced from the shell command "libindex liball.so -o lib1.o lib2.o > index".  The liball.so is composed of lib1.o and lib2.o.
I doubt the correctness of index file although I have no experience of libraryopt before.  In other hand, I traced into libopt and found that it did not include lib1.o while process the undefined symbol show1 of go.  So the optimized liball.so even does not have show1 function in it(I use nm to list its symbols).  Could you help to answer it?  Thanks

light
0
 

Accepted Solution

by:
lightlu earned 0 total points
Comment Utility
I found the answer.  The problem is the way to create so file.  The commans should be "gcc -o liball.so -shared -g -O2 -fPIC lib1.o lib2.o".  Now I can optimize liball.so that onlu incudes lib1.o which referenced by go program.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now