2017年11月2日 星期四

pthread operation not permitted error

出現這種錯誤, 看起來是因為Ubuntu基於安全性的考量, 在使用ptrace時有所限制.
而限制的設定檔在/etc/sysctl.d/10-ptrace.conf
預設內容為: kernel.yama.ptrace_scope = 1

A PTRACE scope of "0" is the more permissive mode.
A scope of "1" limits # PTRACE only to direct child processes.

只要把kernel.yama.ptrace_scope 改為0, 然後重新開機即可.

PS:如果你的帳號可以sudo的話, 那也可以用sudo 或root去執行你的程式, 這種情況下是不會被限制的.

2017年9月25日 星期一

GCC編譯錯誤: relocation truncated to fit: R_X86_64_32S against symbol `xxxxx` defined in `.bss' section in xxxxx



在GCC的編譯參數加入"-mcmodel=xxxx", 即可解決這個編譯錯誤的問題

-mcmodel=tiny
Generate code for the tiny code model. The program and its statically defined symbols must be within 1GB of each other. Pointers are 64 bits. Programs can be statically or dynamically linked. This model is not fully implemented and mostly treated as ‘small’.
-mcmodel=small
Generate code for the small code model. The program and its statically defined symbols must be within 4GB of each other. Pointers are 64 bits. Programs can be statically or dynamically linked. This is the default code model.
-mcmodel=large
Generate code for the large code model. This makes no assumptions about addresses and sizes of sections. Pointers are 64 bits. Programs can be statically linked only.

2017年3月15日 星期三

Beej's Guide to Network Programming

發現一本寫的還不錯的Linux socket 網路程式設計書, 對初學者而言是一份很好的開始

Beej's Guide to Network Programming
譯者:Aaron Liao(廖明沂),May, 2014

GitBook:Beej's Guide to Network Programming GitBook

繁體中文網頁版: http://beej-zhtw.netdpi.net/
英文官網: http://beej.us/guide/bgnet/