mirror of
https://github.com/rui314/mold.git
synced 2024-12-24 17:01:50 +03:00
temporary
This commit is contained in:
parent
0c4c8a0a50
commit
6511d0965f
24
main.cc
24
main.cc
@ -3,6 +3,7 @@
|
||||
#include "llvm/BinaryFormat/Magic.h"
|
||||
#include "llvm/Option/ArgList.h"
|
||||
#include "llvm/Support/FileOutputBuffer.h"
|
||||
#include "llvm/Support/FileSystem.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <iostream>
|
||||
@ -14,6 +15,7 @@
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::ELF;
|
||||
using namespace llvm::sys;
|
||||
|
||||
using llvm::object::Archive;
|
||||
using llvm::opt::InputArgList;
|
||||
@ -587,6 +589,17 @@ static int parse_filler(opt::InputArgList &args) {
|
||||
return (u8)ret;
|
||||
}
|
||||
|
||||
static std::string find_library(StringRef name) {
|
||||
for (StringRef dir : config.library_paths) {
|
||||
if (std::string path = (dir + "/lib" + name + ".a").str(); fs::exists(path))
|
||||
return path;
|
||||
if (!config.is_static)
|
||||
if (std::string path = (dir + "/lib" + name + ".so").str(); fs::exists(path))
|
||||
return path;
|
||||
}
|
||||
error("library not found: " + name);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
// Parse command line options
|
||||
MyOptTable opt_table;
|
||||
@ -613,9 +626,16 @@ int main(int argc, char **argv) {
|
||||
// Open input files
|
||||
{
|
||||
MyTimer t("open", parse_timer);
|
||||
for (auto *arg : args)
|
||||
if (arg->getOption().getID() == OPT_INPUT)
|
||||
for (auto *arg : args) {
|
||||
switch (arg->getOption().getID()) {
|
||||
case OPT_INPUT:
|
||||
read_file(arg->getValue());
|
||||
break;
|
||||
case OPT_library:
|
||||
read_file(find_library(arg->getValue()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parse input files
|
||||
|
36
test/library-path-static.s
Normal file
36
test/library-path-static.s
Normal file
@ -0,0 +1,36 @@
|
||||
// RUN: cc -o %t.o -c %s
|
||||
// RUN: mold -static -o %t.exe \
|
||||
// RUN: /usr/lib/x86_64-linux-gnu/crt1.o \
|
||||
// RUN: /usr/lib/x86_64-linux-gnu/crti.o \
|
||||
// RUN: /usr/lib/gcc/x86_64-linux-gnu/9/crtbeginT.o \
|
||||
// RUN: -L/usr/lib/gcc/x86_64-linux-gnu/9 \
|
||||
// RUN: -L/usr/lib/x86_64-linux-gnu \
|
||||
// RUN: -L/usr/lib64 \
|
||||
// RUN: -L/lib/x86_64-linux-gnu \
|
||||
// RUN: -L/lib64 \
|
||||
// RUN: -L/usr/lib/x86_64-linux-gnu \
|
||||
// RUN: -L/usr/lib64 \
|
||||
// RUN: -L/usr/lib64 \
|
||||
// RUN: -L/usr/lib \
|
||||
// RUN: -L/lib \
|
||||
// RUN: -L/usr/lib \
|
||||
// RUN: %t.o \
|
||||
// RUN: -lgcc \
|
||||
// RUN: -lgcc_eh \
|
||||
// RUN: -lc \
|
||||
// RUN: /usr/lib/gcc/x86_64-linux-gnu/9/crtend.o \
|
||||
// RUN: /usr/lib/x86_64-linux-gnu/crtn.o
|
||||
// RUN: %t.exe | grep 'Hello world'
|
||||
|
||||
.text
|
||||
.globl main
|
||||
main:
|
||||
lea msg(%rip), %rdi
|
||||
xor %rax, %rax
|
||||
call printf
|
||||
xor %rax, %rax
|
||||
ret
|
||||
|
||||
.data
|
||||
msg:
|
||||
.string "Hello world\n"
|
Loading…
Reference in New Issue
Block a user