emscripten-core / emscripten-core/emscripten

[feature request] Rename symbols ("--redefine-sym") or alter the binding of a symbol in wasm-ld (c.f end of issue)

Đang mở
#12,167 33 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C++
Star
27.6k
Fork
3.6k
Merge trung bình
1 ngày 6 giờ
Pull request đã merge (30 ngày)
109

Mô tả

**ORIGINAL ISSUE TITLE**: Duplicate symbols when building a busybox-like tool
I'm building a xetex+dvipdfmx busybox-like two-in-one executable with Emscripten. I redefined names of main functions using compiler `-Dmain=...` argument.

I have:
```
libxetex.a
someobjectfile.o jpegimage.o oldxetexmain.o (contains busymain_xetex)

libdvidpfmx.a
someotherobjectfile.o jpegimage.o main.o olddvipdfmxmain.o (contains busymain_dvipdfmx)
```

Both `jpegimage.o` functions are used in `someobjectfile.o`/`someotherobjectfile.o` and export same-named symbols which causes duplicate symbols. Unfortunately the two copies of jpegimage.o are not guaranteed to be exactly same.

At the end of the day I'm interested to only link to `busymain_*` functions and hide all other symbols. Is there a way with Emscripten/llvm-wasm to postproc the static library `*.a` files and hide all unnecessary symbols prior to linking to the final `main.c`?

```cpp
/* main.c */

#include

extern int busymain_xetex(int argc, char* argv[]);
extern int busymain_dvipdfmx(int argc, char* argv[]);

int main(int argc, char* argv[])
{
if(strcmp("xetex", argv[1]) == 0)
return busymain_xetex(argc - 1, argv + 1);
else
return busymain_dvipdfmx(argc - 1, argv + 1);
}
```

Thank you!

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.