All about symbol versioning
Updated in 2023-08.
Many people just want to know how to define or reference versioned symbols properly. You may jump to Recommended usage below.
In 1995, Solaris' link editor and ld.so introduced the symbol versioning mechanism. Ulrich Drepper and Eric Youngdale borrowed Solaris' symbol versioning in 1997 and designed the GNU style symbol versioning for glibc.
Explain GNU style linker options
Updated in 2025-02
(首先庆祝一下LLVM 2000 commits达成!)
Compiler driver options
Before describing the linker options, let's introduce the concept of
driver options. The user-facing options of gcc
and
clang
are called driver options. Some driver options affect
the options passed to the linker. Many such options have the same name
as the linker's, and they often have additional functions in addition to
the options of the same name passed to the linker, such as:
Stack unwinding
Update in 2024-01.
The main usage of stack unwinding is:
- To obtain a stack trace for debugger, crash reporter, profiler, garbage collector, etc.
- With personality routines and language specific data area, to implement C++ exceptions (Itanium C++ ABI). See C++ exception handling ABI
模块内函数调用和libc符号重命名
Translation unit外的函数调用
Command line processing in LLVM
Updated in 2023-05.
There are two libraries for processing command line options in LLVM.
llvm/Support/ComandLine.h
See https://llvm.org/docs/CommandLine.html for documentation.
Global variables (mostly llvm::cl::opt<type>
, some
llvm::cl::list<type>
) are most common to represent
command-line options. The llvm::cl::opt
constructor
registers this command line option in a global registry. The program
calls llvm::cl::ParseCommandLineOptions(argc, argv, ...)
in
main
to parse the command line options. opt
supports various integer types, bool
,
std::string
, etc. Defining some specialization can support
support custom class/enum types.
gcov与LLVM中的实现
打算以后不定期写一点LLVM的学习(开发)笔记。写作上不想过多花时间(加语文水平所限...),所以字句不作过多斟酌。
gcov
https://gcc.gnu.org/onlinedocs/gcc/Gcov.html
_Optimally Profiling and Tracing Programs_描述了一个edge-frequency/edge-placement problem。 选择control-flow graph的一些边,加上监控代码,推导所有边的执行次数。 gcov是一种实现。
在gcov的模型中,一个源文件包含若干函数,一个函数包含若干基本块,一个基本块占据若干行,这些信息保存在.gcno
文件中。
Instrument程序,在基本块间转移时记录边的执行次数,程序退出时为每个translation
unit输出一个.gcda
文件。
.gcda
文件可以累计多次程序执行的计数。
从-fpatchable-function-entry=N[,M]说起
Linux kernel用了很多GCC选项支持ftrace。
2019年总结——工具链的一年
2017年10月第一次给LLVM提交patch,到2019年底已经贡献两年多了。今年800 commits,灌水很多,挑出一些值得一提的。
C++ language server ccls一周年
2018年4月1日我写了ccls: a fork of the C++ language server cquery,宣告ccls诞生。如今一周年,有必要记录下这一年的点点滴滴。