duangsuse::Echo
720 subscribers
4.3K photos
131 videos
583 files
6.54K links
import this:
美而不丑、明而不暗、短而不凡、长而不乱,扁平不宽,读而后码,行之天下,勿托地上天国。
异常勿吞,难过勿过,叹一真理。效率是很重要,盲目最是低效。
简明是可靠的先验,不是可靠的祭品。
知其变,守其恒,为天下式;穷其变,知不穷,得地上势。知变守恒却穷变知新,我认真理,我不认真。

技术相干订阅~
另外有 throws 闲杂频道 @dsuset
转载频道 @dsusep
极小可能会有批评zf的消息 如有不适可退出
suse小站(面向运气编程): https://WOJS.org/#/
Download Telegram
Forwarded from dnaugsuz
nm target/debug/libex.so
U abs@@GLIBC_2.2.5
0000000000201008 b bss_start
0000000000000600 T c_abs
0000000000000630 T c_mkdir
0000000000201008 b completed.6991
0000000000000660 T c_print
w __cxa_finalize@
@GLIBC_2.2.5
0000000000000520 t deregister_tm_clones
00000000000005b0 t __do_global_dtors_aux
0000000000200df8 t __do_global_dtors_aux_fini_array_entry
0000000000201000 d __dso_handle
0000000000200e00 d _DYNAMIC
0000000000201008 d _edata
0000000000201010 b _end
0000000000000684 t _fini
00000000000005f0 t frame_dummy
0000000000200df0 t __frame_dummy_init_array_entry
0000000000000780 r __FRAME_END

0000000000200fb0 d _GLOBAL_OFFSET_TABLE_
w gmon_start
0000000000000690 r GNU_EH_FRAME_HDR
00000000000004d8 t _init
w _ITM_deregisterTMCloneTable
w _ITM_registerTMCloneTable
U mkdir@
@GLIBC_2.2.5
U printf@
@GLIBC_2.2.5
0000000000000560 t register_tm_clones
0000000000201008 d __TMC_END


🌚拿去Python的ctypes玩会,没有libstd好轻巧(
Forwarded from dnaugsuz
llvm-objdump -d target/release/libex.so
c_abs:
5d0: 89 f8 movl %edi, %eax
5d2: f7 d8 negl %eax
5d4: 0f 4c c7 cmovll %edi, %eax
5d7: c3 retq
5d8: 0f 1f 84 00 00 00 00 00 nopl (%rax,%rax)

c_mkdir:
5e0: bf 0c 00 00 00 movl $12, %edi
5e5: be f3 02 00 00 movl $755, %esi
5ea: e9 e1 fe ff ff jmp -287 <.plt.got>
5ef: 90 nop

c_print:
5f0: bf 0c 00 00 00 movl $12, %edi
5f5: 31 c0 xorl %eax, %eax
5f7: e9 dc fe ff ff jmp -292 <.plt.got+0x8>
Forwarded from dnaugsuz
这时候我发现snowman给出的反编译结果🌚
int64_t printf = 0;

int32_t fun_510(int64_t rdi) {
goto printf;
}
int64_t c_print() {
int32_t eax1;
int64_t rax2;

eax1 = fun_510(12);
*reinterpret_cast<int32_t*\>\(&rax2) = eax1;
*reinterpret_cast<int32_t*\>\(reinterpret_cast<int64_t\>\(&rax2) + 4) = 0;
return rax2;
}
虽然垃圾的不知道到那里去了,但的确比反汇编的好...
Forwarded from dnaugsuz
»> c.c_print()
[1] 29596 segmentation fault (core dumped) python
»> c.c_mkdir()
-1
ls .
Cargo.lock Cargo.toml src target
»> c.c_abs(1)
1
»> c.c_abs(-1)
1
»> c.c_abs()
11
Forwarded from dnaugsuz
»> c=ctypes.CDLL("target/debug/libex.so")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/ctypes/init.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: target/debug/libex.so: undefined symbol: rust_begin_unwind
»>
Forwarded from dnaugsuz
我想结果大概就是:除了写起来蹩脚外基本没有区别...
Forwarded from dnaugsuz
即使这样的话还是要拿Rust的语法在写C?
Forwarded from dnaugsuz
🙈 我自己的锅,因为我填的是 c dylib,如果是Rust的话就是dylib...
Forwarded from dnaugsuz
676 target/release/libex.so
一上Rust体积就开始膨胀,我看这药丸即使是拿rustc编译C程序也无所谓了吧...233
Forwarded from dnaugsuz
于是我默默的加上了#![no_core], 即使是打着写Rust的旗号在写C也无所谓了... 😒
Forwarded from dnaugsuz
»> ctypes.cdll.LoadLibrary("target/release/libex.so")
<CDLL 'target/release/libex.so', handle 54b3573170 at 0x7f171f1b0ef0>
»> c=ctypes.cdll.LoadLibrary("target/release/libex.so")
»> c.c_print()
Hello, World!
0

8 target/release/libex.so
看到有这么好的福利,而且还非常廉价,duangsuse迅速收回之前的言论选择了libcore 🌚
duangsuse::Echo
libex.so
这个大小吼, 非常支辞
from ctypes import cdll
c_ex=cdll.LoadLibrary("./libex.so")
c_ex.abs(-1)
c_ex.c_hello()
Guid guid = Guid.NewGuid();
Console.WriteLine(guid);
^C#生成&printlnGUID
csharp [filename]
duangsuse::Echo
mind
改了一下,为了体积不使用std和toml格式了,用自创格式.并且x86和armv7的也不需要独立apk了,因为编译出cdylib的大小完全可以被接受,而且现在Rust
部分只负责扫描和删除(使用libc)了,其他(解析规则)由Java部分完成,并且不再使用文件交换数据,充分利用FFI的优越性传递参数.并且这样出第一版就可以做PV了
duangsuse::Echo
a.tar.bz2
core-only Rust helloworld cdylib use in JNI🌚