On Mon, 21 May 2018 07:21:38 +1000
Paul Edwards <mutazi...@gmail.com> wrote:

> When 32-bit modules are created on z/Linux
> using "gcc -m32" or whatever, is the resultant
> module run as AM31 or AM64?

The -m31 option creates objects and binaries in the ELF32 format.
Without the option or with -m64 the ELF64 format is used.

A 64-bit kernel recognizes the format of the binary and starts it
in the appropriate mode. Native for ELF64 or compat for ELF32.
The addressing mode is AMODE-64 for native 64-bit programs and
AMOED-31 for compat 31-bit code.

> If the answer is AM31, then what happens if it
> is run as AM64 instead?

The process is started by the kernel in the "correct" mode,
you can not specify that a ELF32 binary is started in AMODE-64.

The kernel enforces limits as well, e.g. with a 31-bit compat
process (ELF32) you can not map anything above the 2GB line.
The format of the signal handler frame is different as well
for ELF32 vs ELF64.

But you can switch the addressing mode in your program with
the sam24, sam31, and sam64 instructions. If the code of the
program is at a location that goes along with the chosen
addressing mode, the CPU will happily execute the instructions.
You better not forget to switch back to the default mode before
calling a function in the runtime environment. Otherwise your
program will quickly terminate.

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to lists...@vm.marist.edu with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390
----------------------------------------------------------------------
For more information on Linux on System z, visit
http://wiki.linuxvm.org/

Reply via email to