llvm

Is anyone able to get the Address-Sanitizer (known as asan or -fsanitize=address) working on iOS?

≡放荡痞女 提交于 2019-12-06 04:13:21
问题 Address-Sanitizer https://code.google.com/p/address-sanitizer/wiki/AddressSanitizer I have compile my own llvm (pretty straight forward compiling) because apple's llvm not support this function. I have tested the clang for mac command line program, it works (but without showing the line the sourcecode). for iOS, there is still some problems: compile simulator version : report error for pre-compiled header: In file included from /Users/fluke/Documents/projects/tmp/testAsanNoARC/testAsanNoARC

Identify array type in IR

强颜欢笑 提交于 2019-12-06 03:25:59
I have been trying to identify array access in IR by making use of following code: for (BasicBlock::iterator ii = BB->begin(), ii2; ii != BB->end(); ii++) { Instruction *I=ii; if(GetElementPtrInst *getElePntr = dyn_cast<GetElementPtrInst>(&*I)) { Value *valAlloc = (getElePntr->getOperand(0)); if(getElePntr->getOperand(0)->getType()->isArrayTy()) { errs()<<"\tarray found"; } } } This code identifies getElementPtr instruction but it does not identify whether it's first operand is an array type or not. Please let me know what is the problem with my code. The first operand of a GEP ( getelementptr

How to load LLVM bitcode file from an ifstream?

若如初见. 提交于 2019-12-06 02:36:36
问题 I'm trying to load an LLVM module defined in a .bc file at runtime but have run into a snag. The bitcode of interest has been generated from hello.cpp : // hello.cpp // build with: // clang-3.4 -c -emit-llvm hello.cpp -o hello.bc #include <iostream> void hello() { std::cout << "Hello, world!" << std::endl; } When the program below attempts to load it at runtime, it crashes inside llvm::BitstreamCursor::Read() : // main.cpp // build with: // g++ main.cpp `llvm-config-3.4 --cppflags --ldflags -

几维安全APP安全加固率先实现Android Q Beta兼容支持

好久不见. 提交于 2019-12-06 02:32:19
日前,谷歌官宣,Android最新版本——Android Q Beta正式对外发布,几维安全第一时间追踪Android系统技术动态,对APP安全加固进行技术攻关和产品升级适配,实现兼容支持。 本次谷歌发布的Android Q版本在注重技术创新的同时,也在加速推进安全与隐私方面的工作,确保为用户提供更安全的系统环境。 Android Q具体更新细节包括:添加了多项隐私及安全防护功能,以及一系列新特性与优化项,如应用文件存储空间限制、禁止访问不可更改的ID、位置权限三态化等。 Android Q系统的新特性 1.暗黑模式 Android Q 的暗黑模式和 Android Pie 的暗黑模式不同,在 Android Q 中,暗黑模式适用于任何地方,如果应用不支持暗黑模式,那么系统将自动设置一个暗黑模式。 2.桌面模式 Android Q 将支持桌面模式,类似三星 Dex 和华为的投影模式。它提供类似一个类似于 PC 的体验,但是远远不能代替 PC。 3.隐私增强 Android Q 还将更多地使用 Android Pie 中推出的隐私功能。 在 Android Q中,您可以选择应用程序在后台运行时是否可以访问该位置。 4.锁定运营商 如果购买运营商定制的Android Q手机,系统将阻止用户使用其他运营商的SIM卡。 5.屏幕录制 Android Q支持屏幕录制,用户可以通过长时间按下

Run LLVM pass with opt

送分小仙女□ 提交于 2019-12-06 01:13:01
I have just started to work with LLVM. I have wrote my own Hello pass, which worked fine. Now I want to run opt with the stack protector pass, from StackProtector.cpp, but I am having trouble with that. When I look at the source code, it looks like I should use the flag -stack-protector: INITIALIZE_PASS(StackProtector, "stack-protector", "Insert stack protectors", false, false) But this flag is not recognized by opt. I am not sure which file to "load", as it is not as simple as loading my own LLVMHello.so file and I could not find a StackProtector.so file; I believe this might be the problem.

Issues running a simple out of source LLVM pass

淺唱寂寞╮ 提交于 2019-12-06 00:27:03
I have been trying to write an LLVM Pass Following a mixture of this and this part of the documentation. I am assuming that since Mac comes with Clang and LLVM I should be able to use their installation to create plugins. So I made a directory layout as follows: optimizations CMakeLists.txt (--> outer) Hello CMakeLists.txt (--> inner) Hello.cpp The contents of "outer" is: find_package(LLVM REQUIRED CONFIG) list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") include(AddLLVM) add_definitions(${LLVM_DEFINITONS}) include_directories(${LLVM_INCLUDE_DIRS}) add_subdirectory(Hello) The contents of

Can I compile a function with gcc and then use it with clang?

时光怂恿深爱的人放手 提交于 2019-12-05 23:16:46
问题 I am trying to use SSE4.2 intrinsics with clang/llvm but its not compiling, as I get cannot select intrinsic error from LLVM. On the other hand, the same code compiles flawlessly in gcc. So I thought, maybe I can compile that function with gcc, so as to have an object or library file, and then call that library function in my code, which is compiled by clang/llvm. Would that work? 回答1: It's possible to compile an object file with GCC in Linux and convert it to work in Visual Studio. I did

LLVM 与 Clang 及其关系

拥有回忆 提交于 2019-12-05 22:53:55
随着 Android P 的逐步应用,越来越多的客户要求编译库时用 libc++ 来代替 libstdc++。libc++ 和 libstdc++ 这两个库有关系呢?它们两个都是 C++ 标准库,libc++ 是针对 Clang 编译器特别重写的 C++ 标准库,而 libstdc++ 则是 GCC 的对应 C++ 标准库了。从 Android 市场来说,Android NDK 已在具体应用中放弃了 GCC,全面转向 Clang,正如很早前 Android NDK 在 Changelog 中提到的那样: Everyone should be switching to Clang. GCC in the NDK is now deprecated. Android NDK 从 r11 开始建议大家切换到 Clang,并且把 GCC 标记为 deprecated,将 GCC 版本锁定在 GCC 4.9 不再更新; Android NDK 从 r13 起,默认使用 Clang 进行编译,但是暂时也没有把 GCC 删掉,Google 会一直等到 libc++ 足够稳定后再删掉 GCC; Android NDK 在 r17 中宣称不再支持 GCC 并在后续的 r18 中删掉 GCC,具体可见 NDK 的 版本历史 。 接下来,简要的介绍一下 Clang。Clang 是一个 C、C++

Vim与clang-format

倖福魔咒の 提交于 2019-12-05 22:30:50
前一段时间因工作需要参与了一个开源项目,在向github提交代码后提示格式校验失败。 项目的管理者告知,要想修改的代码能入库需要使用Clang-Format校验。 需要使用下面的命令对上次的修改重新格式化下: git show HEAD | clang-format-diff-3.9 -p 1 -style=file -i 通过调查了解到此开源项目是使用Clang Tools来管理代码的格式,可使用ClangCheck来校验代码的格式问题,使用clang-format来格式化代码。 我们为什么不可以在IDE中直接集成Clang工具自动格式化代码吗? 我使用的IDE是VIM,我相信如此强大的工具必然能实现此功能,在官网 http://clang.llvm.org/docs/ClangTools.html 我如愿的找到了资料。 首先需要安装clang-format sudo apt-get install clang-format-3.9 ln -s /usr/bin/clang-format-3.9 /usr/bin/clang-format 然后 cd ~/sbin; wget https://raw.githubusercontent.com/llvm/llvm-project/master/clang/tools/clang-format/clang-format.py 再修改

failing to parse C++ using llvm and clang

房东的猫 提交于 2019-12-05 22:28:40
I'm writing a little tool with llvm to parse C and C++ code, but I can't seem to get it to successfully parse C++ at all. I'm probably missing something obvious. This is what I have so far: #include <iostream> #include "llvm/Support/Host.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/raw_ostream.h" #include "clang/Basic/DiagnosticOptions.h" #include "clang/Frontend/TextDiagnosticPrinter.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend