mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Richard B. Johnson" <root@chaos.analogic.com>
To: Nir Livni <nir_l3@netvision.net.il>
Cc: linux-kernel@vger.kernel.org
Subject: Re: shared objects, ELFs and memory usage
Date: Tue, 6 May 2003 09:50:27 -0400 (EDT)	[thread overview]
Message-ID: <Pine.LNX.4.53.0305060938260.5836@chaos> (raw)
In-Reply-To: <001401c313db$767bdb60$ded1b3d4@pinguin>

On Tue, 6 May 2003, Nir Livni wrote:

> Hi all,
> If this is not the mailing list to ask this question - please let me know
> where should I ask it.
>
> I have an executable whose size is almost 2MB, and it uses a shared object
> that is almost 2MB.
> when I run the process, I see (using "top") that the amount of "used memory"
> raises with 4MB. (make sence...). the process seem to share 2MB ("shared"
> column).
>
> When the process forks, it seems that the amount of "used memory" raises
> with 4MB again.
>
> Does it mean the shared object is not really shared ? That doesn't make
> sence...
>
> Help is appreciated.
> Please CC me because I am not subscribed.
>
> Thanks,
> Nir

If your shared object is truly a shared object, then it is shared.
Use `strace` to trace the startup of your program. You should
see it mmap() some portion of your shared object. You can also
put a pause() in you program, then look at /proc/<PID>/maps and
see what your program has memapped.

Note that merely linking some object files together does not
create a shared object! You need to compile any 'C' code
with the '-shared' parameter, and any assembly code needs
to not use COMM variables. Then you need to link them as

	ld -warn-common -O2 -shared -Map Shared.Map $(OBJS) -o $(SLIB)

...where OBJS is you list of object files, and SLIB is your new
shared library.

You can inspect Shared.Map to see what is in the library. When
you link against the shared library, you need to tell the linker
where to find the runtime file, i.e., you need to use -rpath.


Cheers,
Dick Johnson
Penguin : Linux version 2.4.20 on an i686 machine (797.90 BogoMips).
Why is the government concerned about the lunatic fringe? Think about it.


  reply	other threads:[~2003-05-06 13:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-06 14:26 Nir Livni
2003-05-06 13:50 ` Richard B. Johnson [this message]
2003-05-08  9:54 Nir Livni
2003-05-08 10:01 ` William Lee Irwin III
2003-05-08 10:43 Nir Livni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.53.0305060938260.5836@chaos \
    --to=root@chaos.analogic.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nir_l3@netvision.net.il \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®