Thread: one last annoying question ^^

  1. #1
    Registered User
    Join Date
    Aug 2001

    one last annoying question ^^

    again: shared libraries

    whenever i call a function of a shared library, the called function needs to work on the shared library's data.

    thus: do all exported shared library functions do somthing like:

    some_shared_function {
      mov somewhere, ds // back up the current data segment
      mov ax, (the data segment of the library) // prepare the shared libraries data   segment for loading
      lds ax ; load the data segment of the shared library into ds
      (usuall calculations and stuff)
      // restore the old data segment
      mov ax, somewhere
      lds ax ; restore old data segment
      ret // return to the caller
    or how do shared library functions access their data?
    signature under construction

  2. #2
    Registered User
    Join Date
    Jun 2004
    have you ever thought that the compiler/Os do that for you?

  3. #3
    Registered User
    Join Date
    Aug 2001
    well im asking HOW it is done
    not WHO does it for me

    cause in my assembly book it just says: "when you want to access another data segment, simple use lds to load a segment selector it into the ds register, or use a segment override prefix"
    ok, got that.

    then when looking what the inter-segment-call-instruction does it basically sais:
    intersegment-calls require a logical address, thus a segment selector and an offset,
    then cs is set to the segment selector, and eip is set to the offset.

    so performing a far call would set cs to another code segment, but ds is left unchanged. thus if i call a shared library function, that function would work on *my* data, and not *its* data, since ds "points" to my data segment.

    so am i right that in the prolog code of shared library functions one action is to load the appropriate data segment into ds?

    the reason why i try to understand that is cause i want to write a bytecode interpreter but i would like to have shared library support in mind. thus i have to understand whats going on
    signature under construction

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question...
    By TechWins in forum A Brief History of
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  2. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 09:22 PM
  3. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 01:36 PM
  4. Question, question!
    By oskilian in forum A Brief History of
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM
  5. Hi to all! First question, please don't eat me... ^^;;
    By ncrfgs in forum A Brief History of
    Replies: 5
    Last Post: 12-15-2001, 03:36 AM