From: arne@vajhoej.dk   
      
   On 1/8/2025 5:31 PM, hb0815 wrote:   
   > On 1/8/25 23:20, Arne Vajhøj wrote:   
   >> On 1/8/2025 5:11 PM, hb0815 wrote:   
   >>> On 1/8/25 02:58, Arne Vajhøj wrote:   
   >>>> During some troubleshooting over at VSI forum hb told me that   
   >>>> running a shareable image will execute LIB$INITIALIZE   
   >>>> functions.   
   >>>>   
   >>>> That made me write this:   
   >>>   
   >>> Yeah, but ... You do not need init code for this.   
   >>   
   >> Oh.   
   >>   
   >> Can one get a transfer address into a shareable image?   
      
   > $ ty s.c   
   > #include    
   > static int firstFunctionInThisModuleBecomesTheEntryPoint () {   
   > printf ("It's the shareable, stupid!\n");   
   > return 1;   
   > }   
   > int foo () {   
   > printf ("This is %s\n", __func__);   
   > return 1;   
   > }   
   > $ cc s/stand=rel   
   > $ link/share s,tt:/opt ! symbol_v=(foo=proc)   
   > symbol_v=(foo=proc)   
   > Exit   
   > $ r s   
   > It's the shareable, stupid!   
      
   Hmmm.   
      
   It works in C, but it does not seem to work in   
   any other language (tested with Pascal and Fortran).   
      
   $ type prg.c   
   #include    
      
   extern void say();   
      
   int main(int argc, char *argv[])   
   {   
    say();   
    return 0;   
   }   
      
   $ type lib.c   
   #include    
      
   int ooops()   
   {   
    printf("This is a shareable image to link against not run\n");   
    return 1;   
   }   
      
   void say()   
   {   
    printf("Hi\n");   
   }   
      
   $ cc lib   
   $ link/share=libshr lib + sys$input/opt   
   symbol_vector=(say=procedure)   
   $   
   $ define/nolog libshr sys$disk:[]libshr   
   $ cc prg   
   $ link prg + sys$input/opt   
   libshr/share   
   $   
   $ run prg   
   Hi   
   $ run libshr   
   This is a shareable image to link against not run   
   $ type prg.pas   
   program prg(input,output);   
      
   [external]   
   procedure say; external;   
      
   begin   
    say;   
   end.   
   $ type lib.pas   
   [inherit('sys$library:starlet')]   
   module lib(input, output);   
      
   [global]   
   procedure ooops;   
      
   begin   
    writeln('This is a shareable image to link against not run');   
    $exit(ss$_normal);   
   end;   
      
   [global]   
   procedure say;   
      
   begin   
    writeln('Hi');   
   end;   
      
   end.   
   $ pas lib   
   $ link/share=libshr lib + sys$input/opt   
   symbol_vector=(say=procedure)   
   $   
   $ define/nolog libshr sys$disk:[]libshr   
   $ pas prg   
   $ link prg + sys$input/opt   
   libshr/share   
   $   
   $ run prg   
   Hi   
   $ run libshr   
   %DCL-E-NOTFR, no transfer address   
   $ type prg.for   
    program prg   
    call say   
    end   
   $ type lib.for   
    subroutine ooops   
    include '($ssdef)'   
    write(*,*) 'This is a shareable image to link against not run'   
    call sys$exit(ss$_normal)   
    end   
   c   
    subroutine say   
    write(*,*) 'Hi'   
    end   
   $ for lib   
   $ link/share=libshr lib + sys$input/opt   
   symbol_vector=(say=procedure)   
   $   
   $ define/nolog libshr sys$disk:[]libshr   
   $ for prg   
   $ link prg + sys$input/opt   
   libshr/share   
   $   
   $ run prg   
   Hi   
   $ run libshr   
   %DCL-E-NOTFR, no transfer address   
      
   I assume the difference relates to user code main not being   
   the real program entry.   
      
   Arne   
      
   --- SoupGate-DOS v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|