Showing posts with label gcc. Show all posts
Showing posts with label gcc. Show all posts

Monday, June 30, 2014

gcc visibility

在處理某個 bug (https://bugzilla.mozilla.org/show_bug.cgi?id=933588#c26)  時,遇到了 linking error :

hidden symbol '_ZNK7android6Parcel9readInt32Ev' is not defined locally


最後研究了一下
原來是本來的 build system 是用 -fvisibility
這只會影嚮到 definition
但後來用了 prama gcc visibility ,這是更 strong 的 directive, 也會影嚮到 reference 到的 symbol

Monday, November 7, 2011

stack frame alignment

除了structure alignment 外
還有stack frame alignment
http://stackoverflow.com/questions/8004458/compiler-g-seems-to-allocate-more-memory-for-instances-of-classes-than-it-ne


不過有篇post也討論為啥要在32bit上也要用16 byte
不過他好像沒討論出什麼!?
http://blogs.embarcadero.com/abauer/2010/01/14/38904

Friday, January 14, 2011

__aeabi_f2uiz

之前一直遇到jni lib load不起來的問題
一直苦於無法在device上打開linker的log
所以一直不知道到底是什麼原因dlopen會fail掉
而且如果直接把linker換掉
device也就直接爛掉了....

最後只好用肉眼來比較可以load的library跟load 不起來的library
幸好在plt 就看到不一樣了
不能動的lib那多了一個 __aeabi_f2uiz

幸好也有人遇到跟我一樣的問題
而David Tuner剛好也回了他
讓我有個方向來進行
http://groups.google.com/group/android-developers/browse_thread/thread/636d11723aae3117


最後發現 我build的時候 是for emulator的
所以在device上會跑不起來

最後就
source build/envsetup.sh
lunch
然後選要跑的device就解決了aeabi_f2uiz的問題了

2011.11.17
在android-4.0的AOSP裡 libbcc的code
也在RuntimeStub.c看到 他們也遇到 __aeabi_f2uiz missing的問題


 82 #if defined(__arm__)
 83 // NOTE: __aeabi_f2uiz is missing from libgcc which comes with android,
 84 // so here's the workaround.  Remove this when __aeabi_f2uiz is available
 85 // from libgcc.
 86 unsigned int __aeabi_f2uiz(float a)
 87   __attribute__((weak, alias("__fixunssfsi")));
 88 #endi

Monday, May 17, 2010

__thread inside struct

忽然想到
如果__thread可以放到struct裡不就很刺激

小試了一下

26 struct test_t {
 27     int a;
 28     __thread int b;
 29 };

當然是會有compile error ......

Thursday, April 1, 2010

gcc的extension

# define PLUGIN_LOG(A, B...) do { LOGI( A , ## B ); } while(0)

看得懂上面那段code嗎
不要以為##是多的

當你的arg只有一個時 PLUGIN_LOG(A) 你就發現它的重要性了

http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html

Friday, March 19, 2010

Thursday, September 3, 2009

Gold linker

Linker Part1
http://www.airs.com/blog/archives/38
妙的是 levine有留comment喔
可惜lan回 : I don’t actually have a copy to hand....

Linker Part2
http://www.airs.com/blog/archives/39
有點講歷史的感覺

Linker Part3
http://www.airs.com/blog/archives/40

Linker Part4
http://www.airs.com/blog/archives/41
講到了Procedure Linkage Table, Global Offset Table
ELF spec也有講到這東西
PLT:

GOT:
The program linker will create the dynamic relocations which the dynamic linker will use to initialize the GOT at runtime. Unlike the PLT, the dynamic linker always fully initializes the GOT when the program start


GOT會被存在%ebx裡

Linker Part5
http://www.airs.com/blog/archives/42
有介紹到 ELF symbol visibility
不過..... 在ELF spec 跟System V ABI都沒看到這個
原來 這是在System V ABI的update裡
http://www.sco.com/developers/gabi/2000-07-17/contents.html


Linker Part6
http://www.airs.com/blog/archives/43
講Relocation
in general a relocation has a type, a symbol, an offset into the contents, and an addend.
然後講linker怎麼把他轉成executable

Linker Part7
http://www.airs.com/blog/archives/44
Thread Local Storage
comment裡有提到幾個resource
http://dlc.sun.com/pdf/817-1984/817-1984.pdf
http://people.redhat.com/drepper/tls.pdf
http://www.lsd.ic.unicamp.br/~oliva/writeups/TLS/RFC-TLSDESC-x86.txt


Linker Part8
http://www.airs.com/blog/archives/45
ELF Segments

Linker Part9
http://www.airs.com/blog/archives/46
Symbol Versions

Linker Part10
http://www.airs.com/blog/archives/47
Parellel Linking

Linker Part11
http://www.airs.com/blog/archives/48
Archives

Linker Part12
http://www.airs.com/blog/archives/49
Symbol Resolution

Linker Part13
http://www.airs.com/blog/archives/50
Symbol Version Redux

Linker Part14
http://www.airs.com/blog/archives/51
Linking Time Optimization

Linker Part15
http://www.airs.com/blog/archives/52
COMDAT sections

Linker Part16
http://www.airs.com/blog/archives/53
C++ template instantiation

Linker Part17
http://www.airs.com/blog/archives/54
Warning Symbols

Linker Part18
http://www.airs.com/blog/archives/55
Incremental Linking

Linker Part19
http://www.airs.com/blog/archives/56
__start and __stop symbols

Linker Part20
http://www.airs.com/blog/archives/57
Gold linker update