Discussion:
load module loaded address between BPX LOAD (load_hfs) and ptrace+fork+exec?
(too old to reply)
Thomas David Rivers
2018-07-10 17:08:44 UTC
Permalink
In a program, you can issue the BPX LOAD service to load a program
into memory... and similar to the LOAD macro, this returns the address
where the module was loaded, and the starting address.

Now - is there any guarantee that if you then do a BPX FORK and then
a BPX EXEC to execute the module, that the module will be loaded at the same
address in the child?

If the child that is doing the BPX EXEC is running under PTRACE, does that
change things?

If there is such a guarantee, I can't seem to find it documented
anywhere; any
pointers on that?

- Thanks -
- Dave Rivers -
--
***@dignus.com Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com
Charles Mills
2018-07-10 18:05:30 UTC
Permalink
I don't even play a UNIX expert on TV but doesn't FORK give the child a
total clone of the parent's address space? If X (for any X, including a load
module) was at address aaa before the FORK, will it not be at address aaa
for both parent and child after the FORK?

Charles


-----Original Message-----
From: IBM Mainframe Discussion List [mailto:IBM-***@LISTSERV.UA.EDU] On
Behalf Of Thomas David Rivers
Sent: Tuesday, July 10, 2018 10:09 AM
To: IBM-***@LISTSERV.UA.EDU
Subject: load module loaded address between BPX LOAD (load_hfs) and
ptrace+fork+exec?

In a program, you can issue the BPX LOAD service to load a program
into memory... and similar to the LOAD macro, this returns the address
where the module was loaded, and the starting address.

Now - is there any guarantee that if you then do a BPX FORK and then
a BPX EXEC to execute the module, that the module will be loaded at the same
address in the child?

If the child that is doing the BPX EXEC is running under PTRACE, does that
change things?

If there is such a guarantee, I can't seem to find it documented
anywhere; any
pointers on that?

- Thanks -
- Dave Rivers -
--
***@dignus.com Work: (919) 676-0847
Get your mainframe programming tools at http://www.dignus.com

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Peter Hunkeler
2018-07-10 18:37:15 UTC
Permalink
Post by Thomas David Rivers
In a program, you can issue the BPX LOAD service to load a program
into memory... and similar to the LOAD macro, this returns the address
where the module was loaded, and the starting address.
Post by Thomas David Rivers
Now - is there any guarantee that if you then do a BPX FORK and then
a BPX EXEC to execute the module, that the module will be loaded at the same
address in the child?


The fork does a one by one copy of the address space (except from non-UNIXish things such as "DD allocations"). So the "BPX LOADed" load module is still at the same address. However, BPX EXEC is the equivalent of terminating the current job step, and starting a new job step where the BPX EXEC module will be the job step program.


I therefore say the answer is NO.


The only case where it could be loaded at the same address is when the BPX EXECed the load module is the same as the job step load module in the parent address space. But, I have never looked into an EXECed address space to see if that is the case or not.
--
Peter Hunkeler

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to ***@listserv.ua.edu with the message: INFO IBM-MAIN
Loading...