mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
Add filename back into invalid lib test
This commit is contained in:
parent
74e47d959a
commit
52524f1c34
8 changed files with 34 additions and 33 deletions
|
@ -93,8 +93,8 @@ final class LibElf : Library
|
||||||
|
|
||||||
void corrupt(int reason)
|
void corrupt(int reason)
|
||||||
{
|
{
|
||||||
eSink.error(loc, "corrupt ELF object module %.*s %d",
|
eSink.error(Loc.initial, "corrupt ELF object `%.*s` module %.*s %d",
|
||||||
cast(int)module_name.length, module_name.ptr, reason);
|
filename.fTuple.expand, module_name.fTuple.expand, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fromfile = 0;
|
int fromfile = 0;
|
||||||
|
@ -329,7 +329,7 @@ final class LibElf : Library
|
||||||
s = tab.lookup(name.ptr, name.length);
|
s = tab.lookup(name.ptr, name.length);
|
||||||
assert(s);
|
assert(s);
|
||||||
ElfObjSymbol* os = s.value;
|
ElfObjSymbol* os = s.value;
|
||||||
eSink.error(loc, "multiple definition of %s: %s and %s: %s", om.name.ptr, name.ptr, os.om.name.ptr, os.name.ptr);
|
eSink.error(Loc.initial, "multiple definition of %s: %s and %s: %s", om.name.ptr, name.ptr, os.om.name.ptr, os.name.ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -359,7 +359,7 @@ private:
|
||||||
this.addSymbol(om, name, pickAny);
|
this.addSymbol(om, name, pickAny);
|
||||||
}
|
}
|
||||||
|
|
||||||
scanElfObjModule(&addSymbol, om.base[0 .. om.length], om.name.ptr, loc, eSink);
|
scanElfObjModule(&addSymbol, om.base[0 .. om.length], om.name.ptr, filename, eSink);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -94,8 +94,8 @@ final class LibMach : Library
|
||||||
|
|
||||||
void corrupt(int reason)
|
void corrupt(int reason)
|
||||||
{
|
{
|
||||||
eSink.error(loc, "corrupt Mach object module %.*s %d",
|
eSink.error(Loc.initial, "corrupt Mach object `%.*s` module %.*s %d",
|
||||||
cast(int)module_name.length, module_name.ptr, reason);
|
filename.fTuple.expand, module_name.fTuple.expand, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fromfile = 0;
|
int fromfile = 0;
|
||||||
|
@ -323,7 +323,7 @@ private:
|
||||||
this.addSymbol(om, name, pickAny);
|
this.addSymbol(om, name, pickAny);
|
||||||
}
|
}
|
||||||
|
|
||||||
scanMachObjModule(&addSymbol, om.base[0 .. om.length], om.name.ptr, loc, eSink);
|
scanMachObjModule(&addSymbol, om.base[0 .. om.length], om.name.ptr, filename, eSink);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -101,8 +101,8 @@ final class LibMSCoff : Library
|
||||||
|
|
||||||
void corrupt(int reason)
|
void corrupt(int reason)
|
||||||
{
|
{
|
||||||
eSink.error(loc, "corrupt MS Coff object module %.*s %d",
|
eSink.error(Loc.initial, "corrupt MS Coff object `%.*s` module %.*s %d",
|
||||||
cast(int)module_name.length, module_name.ptr, reason);
|
filename.fTuple.expand, module_name.fTuple.expand, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fromfile = 0;
|
int fromfile = 0;
|
||||||
|
@ -400,7 +400,7 @@ private:
|
||||||
this.addSymbol(om, name, pickAny);
|
this.addSymbol(om, name, pickAny);
|
||||||
}
|
}
|
||||||
|
|
||||||
scanMSCoffObjModule(&addSymbol, om.base[0 .. om.length], om.name.ptr, loc, eSink);
|
scanMSCoffObjModule(&addSymbol, om.base[0 .. om.length], om.name.ptr, filename, eSink);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -67,5 +67,4 @@ class Library
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const(char)[] filename; /// the filename of the library
|
const(char)[] filename; /// the filename of the library
|
||||||
Loc loc; /// used for error printing
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import core.checkedint;
|
||||||
|
|
||||||
import dmd.errorsink;
|
import dmd.errorsink;
|
||||||
import dmd.location;
|
import dmd.location;
|
||||||
|
import dmd.root.string : fTuple;
|
||||||
|
|
||||||
nothrow:
|
nothrow:
|
||||||
|
|
||||||
|
@ -29,12 +30,12 @@ enum LOG = false;
|
||||||
* pAddSymbol = function to pass the names to
|
* pAddSymbol = function to pass the names to
|
||||||
* base = array of contents of object module
|
* base = array of contents of object module
|
||||||
* module_name = name of the object module (used for error messages)
|
* module_name = name of the object module (used for error messages)
|
||||||
* loc = location to use for error printing
|
* filename = object file name for error printing
|
||||||
* eSink = where the error messages go
|
* eSink = where the error messages go
|
||||||
*/
|
*/
|
||||||
package(dmd.lib)
|
package(dmd.lib)
|
||||||
void scanElfObjModule(void delegate(const(char)[] name, int pickAny) nothrow pAddSymbol,
|
void scanElfObjModule(void delegate(const(char)[] name, int pickAny) nothrow pAddSymbol,
|
||||||
scope const ubyte[] base, const char* module_name, Loc loc, ErrorSink eSink)
|
scope const ubyte[] base, const char* module_name, const(char)[] filename, ErrorSink eSink)
|
||||||
{
|
{
|
||||||
static if (LOG)
|
static if (LOG)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +44,7 @@ void scanElfObjModule(void delegate(const(char)[] name, int pickAny) nothrow pAd
|
||||||
|
|
||||||
void corrupt(int reason)
|
void corrupt(int reason)
|
||||||
{
|
{
|
||||||
eSink.error(loc, "corrupt ELF object module `%s` %d", module_name, reason);
|
eSink.error(Loc.initial, "corrupt ELF object `%.*s` module `%s` %d", filename.fTuple.expand, module_name, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (base.length < Elf32_Ehdr.sizeof)
|
if (base.length < Elf32_Ehdr.sizeof)
|
||||||
|
@ -54,16 +55,16 @@ void scanElfObjModule(void delegate(const(char)[] name, int pickAny) nothrow pAd
|
||||||
|
|
||||||
if (base[EI_VERSION] != EV_CURRENT)
|
if (base[EI_VERSION] != EV_CURRENT)
|
||||||
{
|
{
|
||||||
return eSink.error(loc, "ELF object module `%s` has EI_VERSION = %d, should be %d",
|
return eSink.error(Loc.initial, "ELF object module `%s` has EI_VERSION = %d, should be %d",
|
||||||
module_name, base[EI_VERSION], EV_CURRENT);
|
module_name, base[EI_VERSION], EV_CURRENT);
|
||||||
}
|
}
|
||||||
if (base[EI_DATA] != ELFDATA2LSB)
|
if (base[EI_DATA] != ELFDATA2LSB)
|
||||||
{
|
{
|
||||||
return eSink.error(loc, "ELF object module `%s` is byte swapped and unsupported", module_name);
|
return eSink.error(Loc.initial, "ELF object module `%s` is byte swapped and unsupported", module_name);
|
||||||
}
|
}
|
||||||
if (base[EI_CLASS] != ELFCLASS32 && base[EI_CLASS] != ELFCLASS64)
|
if (base[EI_CLASS] != ELFCLASS32 && base[EI_CLASS] != ELFCLASS64)
|
||||||
{
|
{
|
||||||
return eSink.error(loc, "ELF object module `%s` is unrecognized class %d", module_name, base[EI_CLASS]);
|
return eSink.error(Loc.initial, "ELF object module `%s` is unrecognized class %d", module_name, base[EI_CLASS]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scanELF(uint model)() nothrow
|
void scanELF(uint model)() nothrow
|
||||||
|
@ -87,7 +88,7 @@ void scanElfObjModule(void delegate(const(char)[] name, int pickAny) nothrow pAd
|
||||||
|
|
||||||
const eh = cast(const(ElfXX_Ehdr)*) base.ptr;
|
const eh = cast(const(ElfXX_Ehdr)*) base.ptr;
|
||||||
if (eh.e_type != ET_REL)
|
if (eh.e_type != ET_REL)
|
||||||
return eSink.error(loc, "ELF object module `%s` is not relocatable", module_name);
|
return eSink.error(Loc.initial, "ELF object module `%s` is not relocatable", module_name);
|
||||||
if (eh.e_version != EV_CURRENT)
|
if (eh.e_version != EV_CURRENT)
|
||||||
return corrupt(__LINE__);
|
return corrupt(__LINE__);
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,9 @@ import core.stdc.stdint;
|
||||||
|
|
||||||
import dmd.errorsink;
|
import dmd.errorsink;
|
||||||
import dmd.location;
|
import dmd.location;
|
||||||
|
|
||||||
//import core.sys.darwin.mach.loader;
|
//import core.sys.darwin.mach.loader;
|
||||||
import dmd.backend.mach;
|
import dmd.backend.mach;
|
||||||
|
import dmd.root.string : fTuple;
|
||||||
|
|
||||||
nothrow:
|
nothrow:
|
||||||
|
|
||||||
|
@ -31,12 +31,12 @@ private enum LOG = false;
|
||||||
* pAddSymbol = function to pass the names to
|
* pAddSymbol = function to pass the names to
|
||||||
* base = array of contents of object module
|
* base = array of contents of object module
|
||||||
* module_name = name of the object module (used for error messages)
|
* module_name = name of the object module (used for error messages)
|
||||||
* loc = location to use for error printing
|
* filename = object file name for error printing
|
||||||
* eSink = where the error messages go
|
* eSink = where the error messages go
|
||||||
*/
|
*/
|
||||||
package(dmd.lib)
|
package(dmd.lib)
|
||||||
void scanMachObjModule(void delegate(const(char)[] name, int pickAny) nothrow pAddSymbol,
|
void scanMachObjModule(void delegate(const(char)[] name, int pickAny) nothrow pAddSymbol,
|
||||||
const ubyte[] base, const char* module_name, Loc loc, ErrorSink eSink)
|
const ubyte[] base, const char* module_name, const(char)[] filename, ErrorSink eSink)
|
||||||
{
|
{
|
||||||
static if (LOG)
|
static if (LOG)
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ void scanMachObjModule(void delegate(const(char)[] name, int pickAny) nothrow pA
|
||||||
|
|
||||||
void corrupt(int reason)
|
void corrupt(int reason)
|
||||||
{
|
{
|
||||||
eSink.error(loc, "corrupt Mach-O object module `%s` %d", module_name, reason);
|
eSink.error(Loc.initial, "corrupt Mach-O object `%.*s` module `%s` %d", filename.fTuple.expand, module_name, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
const buf = base.ptr;
|
const buf = base.ptr;
|
||||||
|
@ -62,12 +62,12 @@ void scanMachObjModule(void delegate(const(char)[] name, int pickAny) nothrow pA
|
||||||
{
|
{
|
||||||
if (header.cputype != CPU_TYPE_I386)
|
if (header.cputype != CPU_TYPE_I386)
|
||||||
{
|
{
|
||||||
eSink.error(loc, "Mach-O object module `%s` has cputype = %d, should be %d", module_name, header.cputype, CPU_TYPE_I386);
|
eSink.error(Loc.initial, "Mach-O object module `%s` has cputype = %d, should be %d", module_name, header.cputype, CPU_TYPE_I386);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (header.filetype != MH_OBJECT)
|
if (header.filetype != MH_OBJECT)
|
||||||
{
|
{
|
||||||
eSink.error(loc, "Mach-O object module `%s` has file type = %d, should be %d", module_name, header.filetype, MH_OBJECT);
|
eSink.error(Loc.initial, "Mach-O object module `%s` has file type = %d, should be %d", module_name, header.filetype, MH_OBJECT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (buflen < mach_header.sizeof + header.sizeofcmds)
|
if (buflen < mach_header.sizeof + header.sizeofcmds)
|
||||||
|
@ -81,12 +81,12 @@ void scanMachObjModule(void delegate(const(char)[] name, int pickAny) nothrow pA
|
||||||
return corrupt(__LINE__);
|
return corrupt(__LINE__);
|
||||||
if (header64.cputype != CPU_TYPE_X86_64)
|
if (header64.cputype != CPU_TYPE_X86_64)
|
||||||
{
|
{
|
||||||
eSink.error(loc, "Mach-O object module `%s` has cputype = %d, should be %d", module_name, header64.cputype, CPU_TYPE_X86_64);
|
eSink.error(Loc.initial, "Mach-O object module `%s` has cputype = %d, should be %d", module_name, header64.cputype, CPU_TYPE_X86_64);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (header64.filetype != MH_OBJECT)
|
if (header64.filetype != MH_OBJECT)
|
||||||
{
|
{
|
||||||
eSink.error(loc, "Mach-O object module `%s` has file type = %d, should be %d", module_name, header64.filetype, MH_OBJECT);
|
eSink.error(Loc.initial, "Mach-O object module `%s` has file type = %d, should be %d", module_name, header64.filetype, MH_OBJECT);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (buflen < mach_header_64.sizeof + header64.sizeofcmds)
|
if (buflen < mach_header_64.sizeof + header64.sizeofcmds)
|
||||||
|
|
|
@ -18,6 +18,7 @@ import dmd.root.string;
|
||||||
|
|
||||||
import dmd.errorsink;
|
import dmd.errorsink;
|
||||||
import dmd.location;
|
import dmd.location;
|
||||||
|
import dmd.root.string : fTuple;
|
||||||
|
|
||||||
nothrow:
|
nothrow:
|
||||||
|
|
||||||
|
@ -30,12 +31,12 @@ private enum LOG = false;
|
||||||
* pAddSymbol = function to pass the names to
|
* pAddSymbol = function to pass the names to
|
||||||
* base = array of contents of object module
|
* base = array of contents of object module
|
||||||
* module_name = name of the object module (used for error messages)
|
* module_name = name of the object module (used for error messages)
|
||||||
* loc = location to use for error printing
|
* filename = object file name for error printing
|
||||||
* eSink = where the error messages go
|
* eSink = where the error messages go
|
||||||
*/
|
*/
|
||||||
package(dmd.lib)
|
package(dmd.lib)
|
||||||
void scanMSCoffObjModule(void delegate(const(char)[] name, int pickAny) nothrow pAddSymbol,
|
void scanMSCoffObjModule(void delegate(const(char)[] name, int pickAny) nothrow pAddSymbol,
|
||||||
scope const ubyte[] base, const char* module_name, Loc loc, ErrorSink eSink)
|
scope const ubyte[] base, const char* module_name, const(char)[] filename, ErrorSink eSink)
|
||||||
{
|
{
|
||||||
static if (LOG)
|
static if (LOG)
|
||||||
{
|
{
|
||||||
|
@ -44,7 +45,7 @@ void scanMSCoffObjModule(void delegate(const(char)[] name, int pickAny) nothrow
|
||||||
|
|
||||||
void corrupt(int reason)
|
void corrupt(int reason)
|
||||||
{
|
{
|
||||||
eSink.error(loc, "corrupt MS-Coff object module `%s` %d", module_name, reason);
|
eSink.error(Loc.initial, "corrupt MS-Coff object `%.*s` module `%s` %d", filename.fTuple.expand, module_name, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
const buf = &base[0];
|
const buf = &base[0];
|
||||||
|
@ -77,16 +78,16 @@ void scanMSCoffObjModule(void delegate(const(char)[] name, int pickAny) nothrow
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (buf[0] == 0x80)
|
if (buf[0] == 0x80)
|
||||||
eSink.error(loc, "object module `%s` is 32 bit OMF, but it should be 64 bit MS-Coff", module_name);
|
eSink.error(Loc.initial, "object module `%s` is 32 bit OMF, but it should be 64 bit MS-Coff", module_name);
|
||||||
else
|
else
|
||||||
eSink.error(loc, "MS-Coff object module `%s` has magic = %x, should be %x", module_name, header.Machine, IMAGE_FILE_MACHINE_AMD64);
|
eSink.error(Loc.initial, "MS-Coff object module `%s` has magic = %x, should be %x", module_name, header.Machine, IMAGE_FILE_MACHINE_AMD64);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Get string table: string_table[0..string_len]
|
// Get string table: string_table[0..string_len]
|
||||||
size_t off = header.PointerToSymbolTable;
|
size_t off = header.PointerToSymbolTable;
|
||||||
if (off == 0)
|
if (off == 0)
|
||||||
{
|
{
|
||||||
eSink.error(loc, "MS-Coff object module `%s` has no string table", module_name);
|
eSink.error(Loc.initial, "MS-Coff object module `%s` has no string table", module_name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
off += header.NumberOfSymbols * (is_old_coff ? SymbolTable.sizeof : SymbolTable32.sizeof);
|
off += header.NumberOfSymbols * (is_old_coff ? SymbolTable.sizeof : SymbolTable32.sizeof);
|
||||||
|
|
|
@ -9,7 +9,7 @@ Use a regex because the path is really strange on Azure (OMF_32, 64):
|
||||||
|
|
||||||
TEST_OUTPUT:
|
TEST_OUTPUT:
|
||||||
----
|
----
|
||||||
Error: corrupt $?:windows=MS Coff|osx=Mach|ELF$ object module $?:windows=fail_compilation\extra-files\fake.lib|fail_compilation/extra-files/fake.a$ $n$
|
Error: corrupt $?:windows=MS Coff|osx=Mach|ELF$ object `$r:.*$` module $?:windows=fail_compilation\extra-files\fake.lib|fail_compilation/extra-files/fake.a$ $n$
|
||||||
----
|
----
|
||||||
*/
|
*/
|
||||||
void main() {}
|
void main() {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue