aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2009-11-16 17:40:03 -0800
committerRuss Cox <rsc@golang.org>2009-11-16 17:40:03 -0800
commit44e51fad2865eb560bd71333c5f8b2f60b60e67b (patch)
treeaf708a74ebf4ee46aeb43cbc8617354d816129e8
parent1cdfe9fa282228027b26ee5bf9c248214f7d1907 (diff)
downloadgo-44e51fad2865eb560bd71333c5f8b2f60b60e67b.tar.gz
go-44e51fad2865eb560bd71333c5f8b2f60b60e67b.zip
6l: fix divide by zero in glibc linker.
repeats 8l change http://code.google.com/p/go/source/detail?r=7594e16b5cf9 Fixes #179. R=iant https://golang.org/cl/154145
-rw-r--r--src/cmd/6l/asm.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/cmd/6l/asm.c b/src/cmd/6l/asm.c
index e5aa42c71b..146245c7bd 100644
--- a/src/cmd/6l/asm.c
+++ b/src/cmd/6l/asm.c
@@ -320,15 +320,22 @@ doelf(void)
addstring(lookup(".interp", 0), linuxdynld);
/*
- * hash table - empty for now.
- * we should have to fill it out with an entry for every
- * symbol in .dynsym, but it seems to work not to,
- * which is fine with me.
+ * hash table.
+ * only entries that other objects need to find when
+ * linking us need to be in the table. right now that is
+ * no entries.
+ *
+ * must have at least 1 bucket, though, to avoid
+ * a divide by zero bug in some copies of the glibc
+ * dynamic loader.
*/
s = lookup(".hash", 0);
s->type = SDATA; // TODO: rodata
s->reachable = 1;
- s->value += 8; // two leading zeros
+ adduint32(s, 1); // nbucket
+ adduint32(s, 1); // nchain
+ adduint32(s, 0); // bucket 0
+ adduint32(s, 0); // chain 0
/* dynamic symbol table - first entry all zeros */
s = lookup(".dynsym", 0);