vsk added a comment.

Thanks for your comments!



================
Comment at: lib/CodeGen/CodeGenFunction.cpp:434
+                                            llvm::Constant *Addr) {
+  if (!CGM.getTriple().isOSDarwin())
+    return Addr;
----------------
pcc wrote:
> I think you can just do this unconditionally. As far as I know, all three 
> object formats should support 32-bit relative relocations on x86 and x86_64, 
> which are the only two architectures which currently support 
> `-fsanitize=function`.
Ok! I'll make this change in the next version of this patch (probably tomorrow).


================
Comment at: lib/CodeGen/CodeGenFunction.cpp:445
+  auto *GV = new llvm::GlobalVariable(CGM.getModule(), Addr->getType(),
+                                      /*isConstant=*/false,
+                                      llvm::GlobalValue::PrivateLinkage, Addr);
----------------
pcc wrote:
> This can be constant I think.
Can the value of the global change if a dynamic library is unloaded? I'm unsure 
about this case: A.dylib and B.dylib both have linkonce_odr definitions of X, 
dyld picks the definition from A, and A is unloaded.


================
Comment at: lib/CodeGen/CodeGenFunction.cpp:463
+  auto *PCRelAsInt =
+      Builder.CreatePtrToInt(EncodedAddr, IntPtrTy, "encoded_addr.int");
+  auto *FuncAsInt = Builder.CreatePtrToInt(F, IntPtrTy, "func_addr.int");
----------------
pcc wrote:
> pcc wrote:
> > Maybe use `Int32Ty` (here and below). That should be sufficient under the 
> > small code model.
> Sorry, I meant that the difference could be truncated to `Int32Ty`, and 
> stored as an integer, not a pointer.
I tried this out but it resulted in a mysterious dyld crash after the indirect 
callee returns, which I've yet to understand. I'll have to try using a Debug 
build of dyld to see what's happening.


https://reviews.llvm.org/D37597



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to