Skip to content

ld370: a second COMMON definition takes the last length; IEWL takes the maximum #103

Description

@mgrossmann

Same code path as #102T_CM is in is_sect_type (ld370.c:157), so a second CM definition overwrites G[gi].len at :1728. The last length wins.

IEWL takes the larger. Its COMMON routine compares the CESD length against the incoming ESD length and keeps the existing one when it is not smaller; for CM + CM it takes the maximum. The mirror case — an incoming SD shorter than an existing CM — is diagnosed (error 57, "COMMON AND SUBROUTINE-SAME NAME") and the CM's larger length is still kept. In both directions IEWL ends up with the larger extent; ld370 ends up with whichever came last. Citations in docs/ld370-iewl-divergences.md.

Why the merge rule is the only safeguard there is

A CM section carries no text and no relocation — the ESD entry is its complete description. IFOX00 has a single idiom for "are we in a DSECT or a COMMON" (TM EESDI,BIT1+BIT2+BIT3) and uses it at exactly two suppression points: the TXT-card punch routine (ifnx5p.asm:607, PUNRTN) and the RLD output routine (ifnx5a.asm:1442, RLDOUT). Both skip.

So there is nothing to cross-check a wrong length against and nothing that fails loudly at link time. A CM merged too small is simply an allocation that is too small: the module links clean, and the first writer past the short extent corrupts its neighbour at runtime.

Reachability — read this before prioritising

as370 never emits CM. esd_ent is called at exactly three sites -- as370.c:2882 (sections: 0x04 for PC, else 0x00), :2883 (0x0a for a weak external, else 0x02) and :2888 (0x01, an LD entry). 0x05 appears at none of them, and a COM statement is rejected before it could: ERROR: Undefined operation code in line N - COM, RC 8 (measured 2026-08-30). A too-short COMMON is therefore not reachable through our own assembler, and implementing COM in as370 would not change that either way.

The reachable path is IFOX00-assembled objects and pre-existing MVS object libraries, which ld370.c:3 names as supported input. This is purely an ld370 concern.

Fixture

Two objects defining the same COMMON with different lengths, assembled by IFOX00 (as370 cannot emit CM). Expected: maximum length. Derived, not yet reproduced on MVS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions