浏览代码

avoid referencing address of extern function from vdprintf

this change is in preparation for upcoming PIC/shared library support.
the intent is to avoid going through the GOT, mainly so that dprintf
is operable immediately, prior to processing of relocations. having
dprintf accessible from the dynamic linker will make writing and
debugging the dynamic linker much easier.
Rich Felker 14 年之前
父节点
当前提交
4ee039f354
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      src/stdio/vdprintf.c

+ 6 - 1
src/stdio/vdprintf.c

@@ -1,11 +1,16 @@
 #include "stdio_impl.h"
 
+static size_t wrap_write(FILE *f, const unsigned char *buf, size_t len)
+{
+	return __stdio_write(f, buf, len);
+}
+
 int vdprintf(int fd, const char *fmt, va_list ap)
 {
 	int r;
 	char buf[BUFSIZ];
 	FILE f = {
-		.fd = fd, .lbf = EOF, .write = __stdio_write,
+		.fd = fd, .lbf = EOF, .write = wrap_write,
 		.buf = buf+UNGET, .buf_size = sizeof buf - UNGET
 	};
 	r = vfprintf(&f, fmt, ap);