MonoOni / binarydist

Mono Binary Builds for Testing
9 stars 0 forks source link

AOT doesn't know how to produce assembly for XCOFF binaries #9

Open NattyNarwhal opened 6 years ago

NattyNarwhal commented 6 years ago

AOT code can't be generated because the assembly generator for the runtime spits out code not appropriate for XCOFF, let alone IBM as.

I think AIX is closer to Windows than anything ELF?

Checklist of known tasks:

NattyNarwhal commented 6 years ago

Initial experimentation

Looks like we need to figure out what's with section headers - does AIX not support subsections? This should be fine on ELF systems, but of course, AIX ain't ELF.

Some other stuff like that might need tweaking...

NattyNarwhal commented 6 years ago

It turns out the answer for GNU vs. IBM as is "don't even bother with GNU as on AIX" in gentler terms. This will require a lot of refactoring....

edelsohn commented 6 years ago

Note that GNU as on AIX is AIX XCOFF syntax. GNU as on AIX does not accept ELF-like syntax as input and translate it to XCOFF format on output.

AIX now supports DWARF debugging. The internals of the DWARF sections are standard DWARF. The names of the sections and DWARF section headers are slightly different. AIX assembler mostly accepts GCC-generated DWARF unchanged.

The rhythm for AIX assembler is a little different, especially the syntax introducing a function. There are pseudo-ops with identical purpose but different name.

The main difference is addressing. AIX XCOFF and Linux ELF are very similar in the concept of position independent addressing, but ELF was designed to delegate the creation of the address table to the linker (Global Offset Table aka GOT), while XCOFF was designed for the compiler to create and manage the address table (Table of Contents aka TOC). It's the same purpose and similar behavior, but requires a little more verbiage in the assembler files.

AIX only supports the traditional COFF sections (text, data, bss) and a few others. For finer granularity, it uses a concept called CSECT

    .csect .my_named_text_section[PR]

    .csect .my_named_data_section[RW]

The "[PR]" and "[RW]" are what XCOFF calls mapping classes. This is a decoration after the CSECT name that instructs the linker how to map the CSECTs to COFF sections. PR for PRogram maps to text. RW for Read/Write maps to data. RO for Read Only maps to text.

One needs a code address (with the dot) and function descriptor (without the dot) for functions.

GCC assembly language output for AIX is a good example to follow.