This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
RE: Dynamic linker issue with bind now?
- From: "Petar Jovanovic" <petar dot jovanovic at rt-rk dot com>
- To: "'Rich Felker'" <dalias at libc dot org>
- Cc: "'Roland McGrath'" <roland at hack dot frob dot com>, <libc-alpha at sourceware dot org>, <petar dot jovanovic at imgtec dot com>, <davem at davemloft dot net>
- Date: Thu, 21 Aug 2014 00:08:05 +0200
- Subject: RE: Dynamic linker issue with bind now?
- Authentication-results: sourceware.org; auth=none
- References: <1408493406-86741-1-git-send-email-petar dot jovanovic at rt-rk dot com> <20140820170817 dot 8C7AE2C3980 at topped-with-meat dot com> <001a01cfbca3$3cf93590$b6eba0b0$ at rt-rk dot com> <20140820185954 dot GH12888 at brightrain dot aerifal dot cx> <002001cfbcab$f16a51a0$d43ef4e0$ at rt-rk dot com> <20140820193020 dot GI12888 at brightrain dot aerifal dot cx>
> I'm guessing it should be possible to write a linker script to
> generate a minimal binary that exhibits the issue,
Yes, that is what I had in mind as well.
Speaking of which, I have just found out that I am not the first one to
report this issue and propose (this) patch.
The issue was reported [1] two years ago, and the issue page has a
small test case. For your convenience, I will copy it here:
$ cat > test.c <<EOF
#include <stdio.h>
static int __attribute__((section(".bar"))) bar = 0x12345678;
static const char foo[] = "foo";
int main() {
printf("%s\n", foo);
return 0;
}
EOF
$ cat > script <<EOF
SECTIONS
{
.bar : { *(.bar) }
}
INSERT AFTER .rela.dyn;
EOF
$ gcc -o test test.c -fPIE -Wl,-T,script
$ LD_BIND_NOW=1 ./test
./test: error while loading shared libraries: unexpected reloc type
0x006008a0
I have just double-checked, and the test case is still valid (and fixed
with the patch). Let me know what you think.
Thank you.
Regards,
Petar
[1] Dynamic linker crash when DT_JMPREL and DT_REL{,A} are not contiguous,
https://sourceware.org/bugzilla/show_bug.cgi?id=14341