[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Shared libs.



  Hi Wolfgang,

  > It could be done even simpler than that: As the data section of a
  > shared library must exist separately in each process, we can allocate
  > its space already at link time (not at load time). The stub routines
  > are then called with the base pointer to the memory in the process'
  > bss area.

  Not possible. A function in a shared module may call a function in
  a different module, which also requires some static storage. At link
  time you don't know about that. You only know which functions are
  directly called by the application. And of course the function
  from moduleA would not know the base address for a function in
  moduleB.

Actually, assuming that a shared library must also use a stub library
to access another shared library, your program can know all of the memory
requirements at link time, assuming you want to go this route. As was
pointed out, it would be nicer to allocate the data at runtime, though,
to allow dynamic replacement of a shared library.

  > This avoids any reentrancy problems. It also avoids the need
  > to deallocate any of the shared library's data sections when the
  > program is finished.


  Waldi