Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #148314

Re: Discarding unneeded object files

From jacobnavia <jacob@jacob.remcomp.fr>
Newsgroups comp.lang.c
Subject Re: Discarding unneeded object files
Date 2019-11-30 23:44 +0100
Organization A noiseless patient Spider
Message-ID <qrurcj$mcc$1@dont-email.me> (permalink)
References <bf115892-5d89-4b5a-91c7-7ef091a433b9@googlegroups.com>

Show all headers | View raw


Le 29/11/2019 à 19:36, Frederick Gotham a écrit :
> I have a 3rd party library which is 50 - 100 source files.
> 
> I compile this library to produce a static shared library. All of the object files are gathered together into an archive (In Linux, this is a ".a" file).
> 
> I then write my own program which links with this static library. For example:
> 
>      gcc main.c -o program -l:libmonkey.a
> 
> When the GNU linker links my own program with the archive file, it only links with the object files inside the archive which are needed.
> 
> If I had not created the archive file... If I had simply linked my own program with all of the 50-100 object files, then my program would have linked with every single object file -- possibly resulting in unreachable code in the output binary.
> 
> So... when the linker links with an archive file, it is smart enough to know which object files are needed, and which are not needed.
> 
> Is there any way to get a list of which object files are actually needed when a program links with an archive file? If I can get such a list, I can remove the redundant object files from the project, and then go on to tweak the object files that are actually needed.
> 
> I need to reduce a library of nearly a hundred source files, to about ten source files, and then go through each of these 10 source files an apply __attribute__ to every function.
> 

You should add the option -M or --print_map to the linker command line. 
This option will generate a listing of all the addresses of all the 
functions in the executable with their correspoçnding OBJECT FILE, so 
you can read the list of object files used very easily.

jacob

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Discarding unneeded object files Frederick Gotham <cauldwell.thomas@gmail.com> - 2019-11-29 10:36 -0800
  Re: Discarding unneeded object files Bart <bc@freeuk.com> - 2019-11-29 19:29 +0000
    Re: Discarding unneeded object files Frederick Gotham <cauldwell.thomas@gmail.com> - 2019-12-01 05:13 -0800
      Re: Discarding unneeded object files gazelle@shell.xmission.com (Kenny McCormack) - 2019-12-01 14:52 +0000
        Re: Discarding unneeded object files Frederick Gotham <cauldwell.thomas@gmail.com> - 2019-12-01 07:01 -0800
          Re: Discarding unneeded object files gazelle@shell.xmission.com (Kenny McCormack) - 2019-12-01 15:06 +0000
          Re: Discarding unneeded object files Richard Damon <Richard@Damon-Family.org> - 2019-12-01 19:32 -0500
            Re: Discarding unneeded object files Frederick Gotham <cauldwell.thomas@gmail.com> - 2019-12-02 00:00 -0800
        Re: Discarding unneeded object files David Brown <david.brown@hesbynett.no> - 2019-12-01 17:17 +0100
  Re: Discarding unneeded object files Richard Damon <Richard@Damon-Family.org> - 2019-11-29 14:30 -0500
  Re: Discarding unneeded object files jacobnavia <jacob@jacob.remcomp.fr> - 2019-11-30 23:44 +0100
  Re: Discarding unneeded object files Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-12-01 08:42 +0000
    Re: Discarding unneeded object files Frederick Gotham <cauldwell.thomas@gmail.com> - 2019-12-01 05:10 -0800
      Re: Discarding unneeded object files gazelle@shell.xmission.com (Kenny McCormack) - 2019-12-01 14:51 +0000
      Re: Discarding unneeded object files Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-12-01 17:26 +0000
        Re: Discarding unneeded object files gazelle@shell.xmission.com (Kenny McCormack) - 2019-12-01 17:43 +0000
          Re: Discarding unneeded object files Richard Damon <Richard@Damon-Family.org> - 2019-12-01 20:04 -0500
    Re: Discarding unneeded object files Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-12-01 09:39 -0800
      Re: Discarding unneeded object files gazelle@shell.xmission.com (Kenny McCormack) - 2019-12-01 17:45 +0000
      Re: Discarding unneeded object files Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-12-02 13:15 +0000
        Re: Discarding unneeded object files Tim Rentsch <tr.17687@z991.linuxsc.com> - 2019-12-06 22:05 -0800

csiph-web