[LLVMdev] possible MachObjectWriter bug (powerpc-darwin8)

David Fang fang at csl.cornell.edu
Sun Mar 10 22:40:39 PDT 2013

 	I've been slowly but steadily working towards enabling the 
Mach-O/PPC backend for MC, starting with the mach-o relocation entry 
patches/logs: http://www.csl.cornell.edu/~fang/sw/llvm/
git: http://github.com/fangism/llvm/tree/powerpc-darwin8
git: http://github.com/fangism/clang/tree/powerpc-darwin8

I've managed to get the simplest single-function-call hello-world program 
to produce a valid PIC object file, validated by comparison against 
/usr/bin/as.  However, as soon as my translation unit contains two 
function calls to extern symbols, the object file looks incorrect.

example program, reduced test case:
extern void foo(void);
extern void goo(void);
extern void bar(void);
void bar(void) { foo(); }
extern void baz(void);
void baz(void) { goo(); }
extern void ick(void);
void ick(void) { bar(); baz(); }

Please see details shown at
from comment 26 to 32+.

Basically, the index into the indirect table for the symbol stubs section 
looks suspect (IndirectSymBase).  I've shown some stack traces that show 
where the wrong(?) value came from, 
MachObjectWriter::BindIndirectSymbols(). Can any mach-o experts comment on 
this finding?  Is there some assumption about the order of symbols or 
sections seen by BindIndirectSymbols()?


David Fang

More information about the llvm-dev mailing list