Commit 927f7ccc by Jim Stichnoth

Subzero: Support non-IRT immediate calls with -filetype=iasm.

This is done by emitting the following: .byte 0xe8 .long __Sz_AbsoluteZero -4 - . The linker is passed an argument like --defsym=__Sz_AbsoluteZero=0 to force the symbol's value to 0. This special symbol is needed due to an llvm-mc parsing bug. BUG= none R=jvoung@chromium.org Review URL: https://codereview.chromium.org/1027593002
parent 5bfe2157
......@@ -146,9 +146,11 @@ def main():
compiler = '{bin}/{prefix}{cc}'.format(
bin=bindir, prefix='pnacl-' if args.sandbox else '',
cc='clang' if pure_c else 'clang++')
sb_native_args = (['-O0', '--pnacl-allow-native', '-arch', 'x8632']
sb_native_args = (['-O0', '--pnacl-allow-native', '-arch', 'x8632',
'-Wn,-defsym=__Sz_AbsoluteZero=0']
if args.sandbox else
['-g', '-m32', '-lm', '-lpthread'])
['-g', '-m32', '-lm', '-lpthread',
'-Wl,--defsym=__Sz_AbsoluteZero=0'])
shellcmd([compiler, args.driver] + objs +
['-o', os.path.join(args.dir, args.output)] + sb_native_args)
......
......@@ -297,6 +297,7 @@ def ProcessPexe(args, pexe, exe):
'{linklib}/libpnacl_irt_shim_dummy.a --start-group ' +
'{linklib}/libgcc.a {linklib}/libcrt_platform.a ' +
'--end-group {linklib}/crtend.o --undefined=_start ' +
'--defsym=__Sz_AbsoluteZero=0 ' +
'-o {exe}'
).format(gold=gold, linklib=linklib, partial=obj_partial, exe=exe,
root=nacl_root),
......@@ -309,7 +310,8 @@ def ProcessPexe(args, pexe, exe):
'{root}/toolchain/linux_x86/pnacl_newlib/translator/x86-32-linux/' +
'lib/{{unsandboxed_irt,irt_random,irt_query_list}}.o ' +
'{root}/toolchain_build/src/subzero/build/runtime/' +
'szrt_native_x8632.o -lpthread -lrt'
'szrt_native_x8632.o -lpthread -lrt ' +
'-Wl,--defsym=__Sz_AbsoluteZero=0'
).format(ld=linker, partial=obj_partial, exe=exe, root=nacl_root),
echo=args.verbose)
......
......@@ -46,13 +46,15 @@ IceString AssemblerFixup::symbol(const GlobalContext *Ctx) const {
return Str.str();
}
void AssemblerFixup::emit(GlobalContext *Ctx) const {
void AssemblerFixup::emit(GlobalContext *Ctx, RelocOffsetT BaseOffset) const {
if (!ALLOW_DUMP)
return;
Ostream &Str = Ctx->getStrEmit();
// TODO(jvoung): Not yet clear how to emit a relocation against
// the null symbol.
assert(!isNullSymbol());
Str << symbol(Ctx);
RelocOffsetT Offset = offset();
if (isNullSymbol())
Str << "__Sz_AbsoluteZero";
else
Str << symbol(Ctx);
RelocOffsetT Offset = offset() + BaseOffset;
if (Offset)
Str << " + " << Offset;
}
......
......@@ -44,7 +44,7 @@ public:
void set_value(const Constant *Value) { value_ = Value; }
void emit(GlobalContext *Ctx) const;
void emit(GlobalContext *Ctx, RelocOffsetT BaseOffset) const;
private:
intptr_t position_;
......
......@@ -136,9 +136,9 @@ void Assembler::emitIASBytes(GlobalContext *Ctx) const {
Str << "\n";
}
Str << "\t.long ";
NextFixup->emit(Ctx);
NextFixup->emit(Ctx, buffer_.Load<RelocOffsetT>(NextFixupLoc));
if (fixupIsPCRel(NextFixup->kind()))
Str << " - (. + " << FixupSize << ")";
Str << " - .";
Str << "\n";
CurPosition = NextFixupLoc + FixupSize;
assert(CurPosition <= EndPosition);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment