Skip to content

Instantly share code, notes, and snippets.

@crabtw
crabtw / llvm-mips.patch
Last active June 6, 2023 06:05
cross compile address sanitizer
Index: lib/Target/Mips/MipsISelLowering.cpp
===================================================================
--- lib/Target/Mips/MipsISelLowering.cpp (revision 182727)
+++ lib/Target/Mips/MipsISelLowering.cpp (working copy)
@@ -1073,7 +1073,14 @@
BuildMI(BB, DL, TII->get(Mips::AND), AlignedAddr)
.addReg(Ptr).addReg(MaskLSB2);
BuildMI(BB, DL, TII->get(Mips::ANDi), PtrLSB2).addReg(Ptr).addImm(3);
- BuildMI(BB, DL, TII->get(Mips::SLL), ShiftAmt).addReg(PtrLSB2).addImm(3);
+ if (Subtarget->isLittle()) {
@crabtw
crabtw / report.rb
Last active December 15, 2015 18:29
require 'write_xlsx'
x = [[
['aaa', 'In Progress', '2013/4/15', 'High'],
['456', 'Done, New'],
['789', 'Done, New'],
]]
wb = WriteXLSX.new('report.xlsx')
ws = wb.add_worksheet
diff --git a/configure b/configure
index a58a0a6..08d6298 100755
--- a/configure
+++ b/configure
@@ -308,8 +308,6 @@ case $CFG_OSTYPE in
esac
-if [ -z "$CFG_CPUTYPE" ]
-then
/* automatically generated by rust-bindgen */
use core::libc::*;
pub type __int8_t = c_schar;
pub type __uint8_t = c_uchar;
pub type __int16_t = c_short;
pub type __uint16_t = c_ushort;
pub type __int32_t = c_int;
pub type __uint32_t = c_uint;
pub type __int64_t = c_long;
@crabtw
crabtw / cmake.scan.sh
Created March 26, 2013 05:35
cross scan-build wrappers
#!/bin/sh
TARGET="mips-unknown-linux-uclibc"
TOOLCHAIN_PATH="$HOME/x-tools/$TARGET"
SYSROOT="$HOME/sysroot/$TARGET"
SCAN_BUILD_DIR="$HOME/src/llvm-svn/tools/clang/tools/scan-build"
SCAN_BUILD_CC="$HOME/bin/$TARGET-clang"
SCAN_BUILD_CXX="$HOME/bin/$TARGET-clang++"
SCAN_BUILD_OUT="analysis"
@crabtw
crabtw / lib.sh
Last active January 20, 2016 01:09
rust cross compile scripts
HOST=x86_64-unknown-linux-gnu
#TARGET=mips-unknown-linux-gnu
#CROSS_TOOL=$HOME/tmp/mips-2013.05/bin
#CXX=mips-linux-gnu-g++
#CXXFLAGS="-shared -fPIC -mips32r2 -msoft-float -mabi=32"
#LLCFLAGS="-march=mips -mcpu=mips32r2 -soft-float -mattr=+mips32r2,+o32 -relocation-model=pic -disable-fp-elim -segmented-stacks"
TARGET=arm-unknown-linux-gnueabihf
CROSS_TOOL=$HOME/tmp/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin
pub struct _XGC {
pub ext_data: *XExtData,
pub gid: GContext,
}
pub type GC = *_XGC;
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp (revision 181993)
+++ lib/Driver/Tools.cpp (working copy)
@@ -6007,8 +6007,12 @@
CmdArgs.push_back("/lib/ld-linux.so.3");
}
else if (ToolChain.getArch() == llvm::Triple::mips ||
- ToolChain.getArch() == llvm::Triple::mipsel)
- CmdArgs.push_back("/lib/ld.so.1");
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+-----------------------------------------------------------------------------------------------+
| | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| two's complement integer | --- | --- | --- | --- | --- | --- | --- | --- |
| | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 256 |
+-----------------------------------------------------------------------------------------------+
float temp_decode(int16_t temp) {
int16_t hi = temp & 0xff00;
int16_t lo = temp & 0x00ff;
return (hi + lo) / 256.0;
}