mirror of
https://github.com/rui314/mold.git
synced 2026-11-09 13:01:26 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e390a70f6c | ||
|
|
d7412d60cc |
No files matched your search
@@ -11,7 +11,7 @@ GIT_HASH ?= $(shell [ -d .git ] && git rev-parse HEAD)
|
||||
OS ?= $(shell uname -s)
|
||||
|
||||
CPPFLAGS = -g -pthread -std=c++20 -fPIE \
|
||||
-DMOLD_VERSION=\"0.9.5\" \
|
||||
-DMOLD_VERSION=\"0.9.6\" \
|
||||
-DGIT_HASH=\"$(GIT_HASH)\" \
|
||||
$(EXTRA_CPPFLAGS)
|
||||
LDFLAGS += $(EXTRA_LDFLAGS)
|
||||
|
||||
@@ -61,7 +61,7 @@ environment, you can build mold by the following commands.
|
||||
$ sudo apt-get install build-essential libstdc++-10-dev cmake clang libssl-dev zlib1g-dev libxxhash-dev git
|
||||
$ git clone https://github.com/rui314/mold.git
|
||||
$ cd mold
|
||||
$ git checkout v0.9.5
|
||||
$ git checkout v0.9.6
|
||||
$ make
|
||||
```
|
||||
|
||||
|
||||
+1
-1
@@ -398,7 +398,7 @@ void InputSection<AARCH64>::scan_relocations(Context<AARCH64> &ctx) {
|
||||
// Absolute Local Imported data Imported code
|
||||
{ NONE, BASEREL, DYNREL, DYNREL }, // DSO
|
||||
{ NONE, BASEREL, DYNREL, DYNREL }, // PIE
|
||||
{ NONE, NONE, DYNREL, DYNREL }, // PDE
|
||||
{ NONE, NONE, COPYREL, PLT }, // PDE
|
||||
};
|
||||
dispatch(ctx, table, i);
|
||||
break;
|
||||
|
||||
+1
-1
@@ -404,7 +404,7 @@ void InputSection<I386>::scan_relocations(Context<I386> &ctx) {
|
||||
// Absolute Local Imported data Imported code
|
||||
{ NONE, BASEREL, DYNREL, DYNREL }, // DSO
|
||||
{ NONE, BASEREL, DYNREL, DYNREL }, // PIE
|
||||
{ NONE, NONE, DYNREL, DYNREL }, // PDE
|
||||
{ NONE, NONE, COPYREL, PLT }, // PDE
|
||||
};
|
||||
dispatch(ctx, table, i);
|
||||
break;
|
||||
|
||||
+1
-1
@@ -556,7 +556,7 @@ void InputSection<X86_64>::scan_relocations(Context<X86_64> &ctx) {
|
||||
// Absolute Local Imported data Imported code
|
||||
{ NONE, BASEREL, DYNREL, DYNREL }, // DSO
|
||||
{ NONE, BASEREL, DYNREL, DYNREL }, // PIE
|
||||
{ NONE, NONE, DYNREL, DYNREL }, // PDE
|
||||
{ NONE, NONE, COPYREL, PLT }, // PDE
|
||||
};
|
||||
dispatch(ctx, table, i);
|
||||
break;
|
||||
|
||||
@@ -861,7 +861,6 @@ void GotSection<E>::copy_buf(Context<E> &ctx) {
|
||||
template <typename E>
|
||||
void PltSection<E>::add_symbol(Context<E> &ctx, Symbol<E> *sym) {
|
||||
ASSERT(!sym->has_plt(ctx));
|
||||
ASSERT(!sym->has_got(ctx));
|
||||
|
||||
if (this->shdr.sh_size == 0) {
|
||||
this->shdr.sh_size = E::plt_hdr_size;
|
||||
@@ -1005,7 +1004,7 @@ void DynsymSection<E>::copy_buf(Context<E> &ctx) {
|
||||
} else if (sym.file->is_dso || sym.esym().is_undef()) {
|
||||
esym.st_shndx = SHN_UNDEF;
|
||||
esym.st_size = 0;
|
||||
if (!ctx.arg.pic && sym.has_plt(ctx) && !sym.has_got(ctx)) {
|
||||
if (sym.has_plt(ctx) && !ctx.arg.pic) {
|
||||
// Emit an address for a canonical PLT
|
||||
esym.st_value = sym.get_plt_addr(ctx);
|
||||
}
|
||||
|
||||
+4
-1
@@ -531,7 +531,10 @@ void scan_rels(Context<E> &ctx) {
|
||||
ctx.got->add_got_symbol(ctx, sym);
|
||||
|
||||
if (sym->flags & NEEDS_PLT) {
|
||||
if (sym->flags & NEEDS_GOT)
|
||||
// If we need to create a canonical PLT (i.e. ctx.arg.pic is false),
|
||||
// we can't use .plt.got because otherwise .plt.got and .plt would
|
||||
// refer each other, resulting in an infinite loop at runtime.
|
||||
if ((sym->flags & NEEDS_GOT) && !ctx.arg.pic)
|
||||
ctx.pltgot->add_symbol(ctx, sym);
|
||||
else
|
||||
ctx.plt->add_symbol(ctx, sym);
|
||||
|
||||
+4
-2
@@ -10,11 +10,13 @@ cat <<EOF | cc -shared -o $t/a.so -xc -
|
||||
void fn() {}
|
||||
EOF
|
||||
|
||||
cat <<EOF | cc -o $t/b.o -c -xc -
|
||||
cat <<EOF | cc -o $t/b.o -c -xc -fno-PIC -
|
||||
#include <stdio.h>
|
||||
|
||||
typedef void Func();
|
||||
|
||||
void fn();
|
||||
void (*ptr)() = fn;
|
||||
Func *const ptr = fn;
|
||||
|
||||
int main() {
|
||||
printf("%d\n", fn == ptr);
|
||||
|
||||
Reference in new issue
Block a user