Commit 6e03343b by Stefan Maksimovic Committed by Jim Stichnoth

Subzero, MIPS32: Sandbox initial patch

Initial patch regarding the Subzero MIPS32 sandboxing stage. At the moment, the results of the crosstests with vector tests disabled are as follows: ASM mode: 19 passing / 5 failing test_bitmanip: O2 test_calling_conv: Om1, O2 test_sync_atomic: Om1, O2 ELF mode: 15 passing / 9 failing test_bitmanip: O2 test_calling_conv: Om1, O2 test_global: Om1, O2 test_stacksave: Om1, O2 test_sync_atomic: Om1, O2 R=stichnot@chromium.org Review URL: https://codereview.chromium.org/2482123002 . Patch from Stefan Maksimovic <makdstefan@gmail.com>.
parent 83425dec
...@@ -15,7 +15,7 @@ def Translate(ll_files, extra_args, obj, verbose, target): ...@@ -15,7 +15,7 @@ def Translate(ll_files, extra_args, obj, verbose, target):
Use pnacl-llc to translate textual bitcode input ll_files into object file Use pnacl-llc to translate textual bitcode input ll_files into object file
obj, using extra_args as the architectural flags. obj, using extra_args as the architectural flags.
""" """
externalize = [] if target == 'mips32' else ['-externalize'] externalize = ['-externalize']
shellcmd(['cat'] + ll_files + ['|', shellcmd(['cat'] + ll_files + ['|',
'pnacl-llc', 'pnacl-llc',
'-function-sections', '-function-sections',
...@@ -24,10 +24,10 @@ def Translate(ll_files, extra_args, obj, verbose, target): ...@@ -24,10 +24,10 @@ def Translate(ll_files, extra_args, obj, verbose, target):
'-bitcode-format=llvm', '-bitcode-format=llvm',
'-o', obj '-o', obj
] + extra_args + externalize, echo=verbose) ] + extra_args + externalize, echo=verbose)
strip_syms = [] if target == 'mips32' else ['nacl_tp_tdb_offset', localize_syms = ['nacl_tp_tdb_offset', 'nacl_tp_tls_offset']
'nacl_tp_tls_offset']
shellcmd([GetObjcopyCmd(target), obj] + shellcmd([GetObjcopyCmd(target), obj] +
[('--strip-symbol=' + sym) for sym in strip_syms]) [('--localize-symbol=' + sym) for sym in localize_syms])
def PartialLink(obj_files, extra_args, lib, verbose): def PartialLink(obj_files, extra_args, lib, verbose):
......
...@@ -580,6 +580,36 @@ public: ...@@ -580,6 +580,36 @@ public:
void lowerArguments() override; void lowerArguments() override;
class Sandboxer {
Sandboxer() = delete;
Sandboxer(const Sandboxer &) = delete;
Sandboxer &operator=(const Sandboxer &) = delete;
public:
explicit Sandboxer(
TargetMIPS32 *Target,
InstBundleLock::Option BundleOption = InstBundleLock::Opt_None);
~Sandboxer();
void addiu_sp(uint32_t StackOffset);
void lw(Variable *Dest, OperandMIPS32Mem *Mem);
void sw(Variable *Dest, OperandMIPS32Mem *Mem);
void lwc1(Variable *Dest, OperandMIPS32Mem *Mem, RelocOp Reloc = RO_No);
void ldc1(Variable *Dest, OperandMIPS32Mem *Mem, RelocOp Reloc = RO_No);
void ret(Variable *RetAddr, Variable *RetValue);
void reset_sp(Variable *Src);
InstMIPS32Call *jal(Variable *ReturnReg, Operand *CallTarget);
private:
TargetMIPS32 *const Target;
const InstBundleLock::Option BundleOption;
std::unique_ptr<AutoBundle> Bundler;
void createAutoBundle();
};
const bool NeedSandboxing;
/// Make a pass through the SortedSpilledVariables and actually assign stack /// Make a pass through the SortedSpilledVariables and actually assign stack
/// slots. SpillAreaPaddingBytes takes into account stack alignment padding. /// slots. SpillAreaPaddingBytes takes into account stack alignment padding.
/// The SpillArea starts after that amount of padding. This matches the scheme /// The SpillArea starts after that amount of padding. This matches the scheme
......
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