X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Far65%2Fobjfile.c;h=11d4de8f7e55332c7224a0656aa6897889433b34;hb=bee54df02967b774c485b0a7fa703b5a76345d4e;hp=e165fc1671064236aea5e3347770ac51a80ddbb5;hpb=bb24d025f6a68c0d1475f82c473ff5102a351db3;p=cc65 diff --git a/src/ar65/objfile.c b/src/ar65/objfile.c index e165fc167..11d4de8f7 100644 --- a/src/ar65/objfile.c +++ b/src/ar65/objfile.c @@ -7,7 +7,7 @@ /* */ /* */ /* (C) 1998-2003 Ullrich von Bassewitz */ -/* Römerstrasse 52 */ +/* Römerstraße 52 */ /* D-70794 Filderstadt */ /* EMail: uz@cc65.org */ /* */ @@ -113,6 +113,8 @@ void ObjReadHeader (FILE* Obj, ObjHeader* H, const char* Name) H->StrPoolSize = Read32 (Obj); H->AssertOffs = Read32 (Obj); H->AssertSize = Read32 (Obj); + H->ScopeOffs = Read32 (Obj); + H->ScopeSize = Read32 (Obj); } @@ -141,6 +143,8 @@ void ObjWriteHeader (FILE* Obj, ObjHeader* H) Write32 (Obj, H->StrPoolSize); Write32 (Obj, H->AssertOffs); Write32 (Obj, H->AssertSize); + Write32 (Obj, H->ScopeOffs); + Write32 (Obj, H->ScopeSize); } @@ -160,8 +164,15 @@ void ObjAdd (const char* Name) Error ("Could not open `%s': %s", Name, strerror (errno)); } - /* Get the modification time of the object file */ - if (fstat (fileno (Obj), &StatBuf) != 0) { + /* Get the modification time of the object file. There a race condition + * here, since we cannot use fileno() (non standard identifier in standard + * header file), and therefore not fstat. When using stat with the + * file name, there's a risk that the file was deleted and recreated + * while it was open. Since mtime and size are only used to check + * if a file has changed in the debugger, we will ignore this problem + * here. + */ + if (stat (Name, &StatBuf) != 0) { Error ("Cannot stat object file `%s': %s", Name, strerror (errno)); } @@ -225,6 +236,8 @@ void ObjAdd (const char* Name) H.LineInfoOffs = LibCopyTo (Obj, H.LineInfoSize) - O->Start; fseek (Obj, H.AssertOffs, SEEK_SET); H.AssertOffs = LibCopyTo (Obj, H.AssertSize) - O->Start; + fseek (Obj, H.ScopeOffs, SEEK_SET); + H.ScopeOffs = LibCopyTo (Obj, H.ScopeSize) - O->Start; /* Calculate the amount of data written */ O->Size = ftell (NewLib) - O->Start;