]> Cypherpunks repositories - gostls13.git/commitdiff
5l/6l/8l: add a DT_DEBUG dynamic tag to a dynamic ELF binary
authorIan Lance Taylor <iant@golang.org>
Wed, 5 Oct 2011 04:25:11 +0000 (21:25 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 5 Oct 2011 04:25:11 +0000 (21:25 -0700)
This requires making the .dynamic section writable, as the
dynamic linker will change the value of the DT_DEBUG tag at
runtime.  The DT_DEBUG tag is used by gdb to find all loaded
shared libraries.

R=rsc
CC=golang-dev
https://golang.org/cl/5189044

src/cmd/5l/asm.c
src/cmd/6l/asm.c
src/cmd/8l/asm.c

index 5b7f6f111d1f9363d97d683cb5f159629fd907b4..46fb6b63236ee098a9bd523865bd0549e2f804bf 100644 (file)
@@ -232,7 +232,7 @@ doelf(void)
                /* define dynamic elf table */
                s = lookup(".dynamic", 0);
                s->reachable = 1;
-               s->type = SELFROSECT;
+               s->type = SELFSECT; // writable
 
                /*
                 * .dynamic table
@@ -251,6 +251,7 @@ doelf(void)
                elfwritedynent(s, DT_PLTREL, DT_REL);
                elfwritedynentsymsize(s, DT_PLTRELSZ, lookup(".rel.plt", 0));
                elfwritedynentsym(s, DT_JMPREL, lookup(".rel.plt", 0));
+               elfwritedynent(s, DT_DEBUG, 0);
                elfwritedynent(s, DT_NULL, 0);
        }
 }
index 3a8223e65cceb5fc7b4b98215ada233898695ba3..8d599ef30aa5ac1cf87f618acdd4bdeb7a3fe342 100644 (file)
@@ -649,7 +649,7 @@ doelf(void)
                /* define dynamic elf table */
                s = lookup(".dynamic", 0);
                s->reachable = 1;
-               s->type = SELFROSECT;
+               s->type = SELFSECT; // writable
 
                /*
                 * .dynamic table
@@ -670,6 +670,8 @@ doelf(void)
                elfwritedynentsymsize(s, DT_PLTRELSZ, lookup(".rela.plt", 0));
                elfwritedynentsym(s, DT_JMPREL, lookup(".rela.plt", 0));
                
+               elfwritedynent(s, DT_DEBUG, 0);
+
                // Do not write DT_NULL.  elfdynhash will finish it.
        }
 }
index 6c7f9648379d6c652ea16c65db21f17d93d9a4cd..03106386c014fe730e2da4c6bdab9c7b638a3eaa 100644 (file)
@@ -607,7 +607,7 @@ doelf(void)
                /* define dynamic elf table */
                s = lookup(".dynamic", 0);
                s->reachable = 1;
-               s->type = SELFROSECT;
+               s->type = SELFSECT; // writable
 
                /*
                 * .dynamic table
@@ -627,6 +627,8 @@ doelf(void)
                elfwritedynentsymsize(s, DT_PLTRELSZ, lookup(".rel.plt", 0));
                elfwritedynentsym(s, DT_JMPREL, lookup(".rel.plt", 0));
 
+               elfwritedynent(s, DT_DEBUG, 0);
+
                // Do not write DT_NULL.  elfdynhash will finish it.
        }
 }