From 2c1292f7097ac5476b9d1c3291f745a13d1009b2 Mon Sep 17 00:00:00 2001
From: Devang Patel
@@ -17,24 +17,24 @@
-
Following example illustrates advantage of integrated approach that uses clean interface. +
-
--- a.h ---
+--- a.h ---
extern int foo1(void);
extern void foo2(void);
extern void foo4(void);
@@ -113,7 +115,7 @@ clean interface.
}
--- main.c ---
-
#include
+
#include < stdio.h >
#include "a.h"
void foo4(void) {
@@ -130,11 +132,10 @@ clean interface.
$ llvm-gcc4 a.o main.o -o main # <-- standard link command without any modifications
-
In this example, the linker recognizes that foo2() is a externally visible symbol defined in LLVM byte code file. This information is collected using - readLLVMByteCodeFile() . Based on this + readLLVMObjectFile() . Based on this information, linker completes its usual symbol resolution pass and finds that foo2() is not used anywhere. This information is used by LLVM optimizer and it removes foo2(). As soon as foo2() is removed, optimizer @@ -153,6 +154,7 @@ optimizer can not remove foo3() without the linker's input.
+
The linker first reads all object files in natural order and collects symbol information. This includes native object files as well as LLVM byte code files. -In this phase, the linker uses readLLVMByteCodeFile() +In this phase, the linker uses readLLVMObjectFile() to collect symbol information from each LLVM bytecode files and updates its internal global symbol table accordingly. The intent of this interface is to avoid overhead in the non LLVM case, where all input object files are native @@ -224,7 +226,7 @@ In this stage, the linker resolves symbols using global symbol table information to report undefined symbol errors, read archive members, resolve weak symbols etc... The linker is able to do this seamlessly even though it does not know exact content of input LLVM bytecode files because it uses symbol information -provided by readLLVMByteCodeFile() . +provided by readLLVMObjectFile() . If dead code stripping is enabled then linker collects list of live symbols.