1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-09 01:28:58 +00:00

Merge pull request #117 from groessler/something_to_pull

Set the "simple" bit in the .o65 mode word only if text, data, and bss are adjacent.
This commit is contained in:
Oliver Schmidt 2014-05-22 09:36:10 +02:00
commit 2c45f43ca2

View File

@ -1320,18 +1320,26 @@ static void O65SetupHeader (O65Desc* D)
SegDesc* FirstSeg = D->ZPSeg [0];
D->Header.ZPBase = FirstSeg->Seg->PC;
}
}
/* If we have byte wise relocation and an alignment of 1, we can set
* the "simple addressing" bit in the header.
static void O65UpdateHeader (O65Desc* D)
/* Update mode word, currently only the "simple" bit */
{
/* If we have byte wise relocation and an alignment of 1, and text
* and data are adjacent, we can set the "simple addressing" bit
* in the header.
*/
if ((D->Header.Mode & MF_RELOC_MASK) == MF_RELOC_BYTE &&
(D->Header.Mode & MF_ALIGN_MASK) == MF_ALIGN_1) {
(D->Header.Mode & MF_ALIGN_MASK) == MF_ALIGN_1 &&
D->Header.TextBase + D->Header.TextSize == D->Header.DataBase &&
D->Header.DataBase + D->Header.DataSize == D->Header.BssBase) {
D->Header.Mode = (D->Header.Mode & ~MF_ADDR_MASK) | MF_ADDR_SIMPLE;
}
}
void O65WriteTarget (O65Desc* D, File* F)
/* Write an o65 output file */
{
@ -1411,6 +1419,9 @@ void O65WriteTarget (O65Desc* D, File* F)
/* Write the list of exports */
O65WriteExports (D);
/* Update header flags */
O65UpdateHeader (D);
/* Seek back to the start and write the updated header */
fseek (D->F, 0, SEEK_SET);
O65WriteHeader (D);