emscripten-core / emscripten-core/emscripten

dl_iterate_phdr in `link.h` header but undefined at link time

Open
#21,354 9 comments 2 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

With emcc 3.1.52 (fa478400df3351f7153c0279bc638784d3d90334):

```C
#define _GNU_SOURCE
#include
#include

int
cb(struct dl_phdr_info *info, size_t size, void *data) {
printf("name: '%s' size: %zu", info->dlpi_name, size);
return 0;
}

int
main() {
dl_iterate_phdr(cb, NULL);
return 0;
}
```
With gcc it works as expected:
```
$ gcc -c a.c
$ gcc a.o
$ ./a.out
name: '' size: 64
name: 'linux-vdso.so.1' size: 64
name: '/lib/x86_64-linux-gnu/libc.so.6' size: 64
name: '/lib64/ld-linux-x86-64.so.2' size: 64
```
With emscripten, it compiles successfully but when I try to link it fails:
```
$ emcc -c a.c -fPIC
$ emcc a.o -sMAIN_MODULE=1
error: undefined symbol: dl_iterate_phdr (referenced by root reference (e.g. compiled C/C++ code))
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.