improved the c-flag, and corrected a bug in the produced relocation info

This commit is contained in:
ceriel 1987-08-26 13:22:44 +00:00
parent 7de2968629
commit c1ffb28416
6 changed files with 22 additions and 17 deletions

View file

@ -119,7 +119,7 @@ handle_relos(head, sects, names)
* Write out the (probably changed) * Write out the (probably changed)
* relocation information. * relocation information.
*/ */
if (flagword & RFLAG) if (flagword & (RFLAG|CFLAG))
wr_relo(relo, 1); wr_relo(relo, 1);
} }
} }
@ -151,7 +151,7 @@ handle_relos(head, sects, names)
* Write out the (probably changed) * Write out the (probably changed)
* relocation information. * relocation information.
*/ */
if (flagword & RFLAG) if (flagword & (RFLAG|CFLAG))
wr_relo(relo, 1); wr_relo(relo, 1);
} }
} }

View file

@ -97,12 +97,10 @@ run.
This flag suppresses the `Undefined:' diagnostic. This flag suppresses the `Undefined:' diagnostic.
.TP .TP
.B \-c .B \-c
Only effective in combination with Indicates that relocation information must be produced, but commons must
.BR \-r .
Indicates that relocatable output must be produced, but commons must
be resolved. be resolved.
This may be useful for machines that need a last relocation step This may be useful for machines that need a last relocation step
at load time. at load time. This flag disables the \fB\-r\fP flag.
.TP .TP
.B \-s .B \-s
`Strip' the output, that is, remove the name table `Strip' the output, that is, remove the name table

View file

@ -162,9 +162,11 @@ first_pass(argv)
break; break;
case 'c': case 'c':
/* /*
* Might be used in combination with 'r', to produce * Leave relocation information in the output, so that
* relocatable output, but handle commons now. * a next pass can see where relocation was done. The
* resulting output however is no longer relocatable.
*/ */
flagword &= ~RFLAG;
flagword |= CFLAG; flagword |= CFLAG;
break; break;
#ifndef NDEBUG #ifndef NDEBUG
@ -188,6 +190,7 @@ first_pass(argv)
* given to common symbols, and suppresses the * given to common symbols, and suppresses the
* `Undefined:' diagnostic. * `Undefined:' diagnostic.
*/ */
if (flagword & CFLAG) break;
if (flagword & SFLAG) if (flagword & SFLAG)
warning("-r contradicts -s: -s ignored"); warning("-r contradicts -s: -s ignored");
flagword |= RFLAG; flagword |= RFLAG;
@ -360,7 +363,7 @@ evaluate()
{ {
norm_commons(); norm_commons();
complete_sections(); complete_sections();
if (!(flagword & RFLAG)) if (!(flagword&RFLAG))
change_names(); change_names();
} }
@ -407,7 +410,7 @@ norm_commons()
} }
name++; name++;
} }
if ((flagword & RFLAG) && !(flagword & CFLAG)) return; if (flagword & RFLAG) return;
/* /*
* RFLAG is off, so we need not produce relocatable output. * RFLAG is off, so we need not produce relocatable output.
@ -454,18 +457,17 @@ complete_sections()
sc->os_foff = foff; sc->os_foff = foff;
foff += sc->os_flen; foff += sc->os_flen;
if ((flagword & RFLAG) && !(flagword & CFLAG)) if (flagword & RFLAG)
continue; continue;
sc->os_size += sect_comm[sectindex]; sc->os_size += sect_comm[sectindex];
if (flagword & RFLAG) continue;
sc->os_lign = sc->os_lign =
tstbit(sectindex, lignmap) ? sect_lign[sectindex] : 1; tstbit(sectindex, lignmap) ? sect_lign[sectindex] : 1;
if (tstbit(sectindex, basemap)) { if (tstbit(sectindex, basemap)) {
base = sect_base[sectindex]; base = sect_base[sectindex];
if (base % sc->os_lign) if (sc->os_lign && base % sc->os_lign)
fatal("base not aligned"); fatal("base not aligned");
} else { } else if (sc->os_lign) {
base += sc->os_lign - 1; base += sc->os_lign - 1;
base -= base % sc->os_lign; base -= base % sc->os_lign;
} }

View file

@ -583,7 +583,7 @@ write_bytes()
/* /*
* The rest depends on the flags. * The rest depends on the flags.
*/ */
if (flagword & RFLAG) if (flagword & (RFLAG|CFLAG))
wr_relo((struct outrelo *) mems[ALLORELO].mem_base, wr_relo((struct outrelo *) mems[ALLORELO].mem_base,
outhead.oh_nrelo); outhead.oh_nrelo);
if (!(flagword & SFLAG)) { if (!(flagword & SFLAG)) {

View file

@ -30,7 +30,7 @@ beginoutput()
if (incore) if (incore)
generate_section_names(); generate_section_names();
if (!(flagword & RFLAG)) if (!(flagword & (CFLAG|RFLAG)))
outhead.oh_nrelo = (ushort)0; outhead.oh_nrelo = (ushort)0;
if (flagword & SFLAG) { if (flagword & SFLAG) {
outhead.oh_nname = (ushort)0; outhead.oh_nname = (ushort)0;

View file

@ -139,6 +139,7 @@ addrelo(relo, names, valu_out)
extern int hash(); extern int hash();
extern struct outname *searchname(); extern struct outname *searchname();
extern ushort indexof(); extern ushort indexof();
extern struct outhead outhead;
name = searchname(local->on_mptr, hash(local->on_mptr)); name = searchname(local->on_mptr, hash(local->on_mptr));
if (name == (struct outname *)0) if (name == (struct outname *)0)
@ -148,7 +149,11 @@ addrelo(relo, names, valu_out)
index += indexof(name); index += indexof(name);
} else { } else {
valu += name->on_valu; valu += name->on_valu;
index += NGlobals + (name->on_type & S_TYP) - S_MIN; if ((name->on_type & S_TYP) == S_ABS) {
index += NGlobals + outhead.oh_nsect;
}
else index += NGlobals +
(name->on_type & S_TYP) - S_MIN;
} }
} }
*valu_out = valu; *valu_out = valu;