mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 21:51:03 +03:00
toobj.d unify pragmas lib/linkerdirective (#16847)
* unify pragmas lib/linkerdirective
This commit is contained in:
parent
0e8e67097d
commit
eeeb43a60f
1 changed files with 16 additions and 28 deletions
|
@ -785,7 +785,7 @@ void toObjFile(Dsymbol ds, bool multiobj)
|
||||||
|
|
||||||
override void visit(PragmaDeclaration pd)
|
override void visit(PragmaDeclaration pd)
|
||||||
{
|
{
|
||||||
if (pd.ident == Id.lib)
|
if (pd.ident == Id.lib || pd.ident == Id.linkerDirective)
|
||||||
{
|
{
|
||||||
assert(pd.args && pd.args.length == 1);
|
assert(pd.args && pd.args.length == 1);
|
||||||
|
|
||||||
|
@ -795,19 +795,25 @@ void toObjFile(Dsymbol ds, bool multiobj)
|
||||||
|
|
||||||
StringExp se = e.isStringExp();
|
StringExp se = e.isStringExp();
|
||||||
char *name = cast(char *)mem.xmalloc(se.numberOfCodeUnits() + 1);
|
char *name = cast(char *)mem.xmalloc(se.numberOfCodeUnits() + 1);
|
||||||
|
|
||||||
se.writeTo(name, true);
|
se.writeTo(name, true);
|
||||||
|
|
||||||
/* Embed the library names into the object file.
|
if (pd.ident == Id.linkerDirective)
|
||||||
* The linker will then automatically
|
obj_linkerdirective(name);
|
||||||
* search that library, too.
|
else
|
||||||
*/
|
|
||||||
if (!obj_includelib(name[0 .. strlen(name)]))
|
|
||||||
{
|
{
|
||||||
/* The format does not allow embedded library names,
|
/* Embed the library names into the object file.
|
||||||
* so instead append the library name to the list to be passed
|
* The linker will then automatically
|
||||||
* to the linker.
|
* search that library, too.
|
||||||
*/
|
*/
|
||||||
global.params.libfiles.push(name);
|
if (!obj_includelib(name[0 .. strlen(name)]))
|
||||||
|
{
|
||||||
|
/* The format does not allow embedded library names,
|
||||||
|
* so instead append the library name to the list to be passed
|
||||||
|
* to the linker.
|
||||||
|
*/
|
||||||
|
global.params.libfiles.push(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (pd.ident == Id.startaddress)
|
else if (pd.ident == Id.startaddress)
|
||||||
|
@ -820,24 +826,6 @@ void toObjFile(Dsymbol ds, bool multiobj)
|
||||||
Symbol *s = toSymbol(f);
|
Symbol *s = toSymbol(f);
|
||||||
obj_startaddress(s);
|
obj_startaddress(s);
|
||||||
}
|
}
|
||||||
else if (pd.ident == Id.linkerDirective)
|
|
||||||
{
|
|
||||||
assert(pd.args && pd.args.length == 1);
|
|
||||||
|
|
||||||
Expression e = (*pd.args)[0];
|
|
||||||
|
|
||||||
assert(e.op == EXP.string_);
|
|
||||||
|
|
||||||
StringExp se = e.isStringExp();
|
|
||||||
size_t length = se.numberOfCodeUnits() + 1;
|
|
||||||
debug enum LEN = 2; else enum LEN = 20;
|
|
||||||
char[LEN] buffer = void;
|
|
||||||
SmallBuffer!char directive = SmallBuffer!char(length, buffer);
|
|
||||||
|
|
||||||
se.writeTo(directive.ptr, true);
|
|
||||||
|
|
||||||
obj_linkerdirective(directive.ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
visit(cast(AttribDeclaration)pd);
|
visit(cast(AttribDeclaration)pd);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue