Plan 9 from Bell Labs’s /usr/web/sources/contrib/yk/dist/9legacy/applied/ld-elf.diff

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


--- /sys/src/cmd/ld/elf.c
+++ /sys/src/cmd/ld/elf.c
@@ -78,12 +78,14 @@ static void
 elf32sectab(void (*putl)(long))
 {
 	seek(cout, HEADR+textsize+datsize+symsize, 0);
+	elf32shdr(putl, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0);
 	elf32shdr(putl, Stitext, Progbits, Salloc|Sexec, INITTEXT,
-		HEADR, textsize, 0, 0, 0x10000, 0);
+		HEADR, textsize, 0, 0, INITRND, 0);
 	elf32shdr(putl, Stidata, Progbits, Salloc|Swrite, INITDAT,
-		HEADR+textsize, datsize, 0, 0, 0x10000, 0);
+		HEADR+textsize, datsize, 0, 0, INITRND, 0);
 	elf32shdr(putl, Stistrtab, Strtab, 1 << 5, 0,
-		HEADR+textsize+datsize+symsize+3*Shdr32sz, 14, 0, 0, 1, 0);
+		HEADR+textsize+datsize+symsize+4*Shdr32sz, 22, 0, 0, 1, 0);
 	elfstrtab();
 }
 
@@ -122,8 +124,8 @@ elf32(int mach, int bo, int addpsects, void (*putpsects)(Putl))
 	putw(3 + addpsects);		/* # of Phdrs */
 	putw(Shdr32sz);
 	if(debug['S']){
-		putw(3);		/* # of Shdrs */
-		putw(2);		/* Shdr table index */
+		putw(4);		/* # of Shdrs */
+		putw(3);		/* Shdr table index */
 	}else{
 		putw(0);
 		putw(0);
@@ -193,12 +195,14 @@ static void
 elf64sectab(void (*putl)(long), void (*putll)(vlong))
 {
 	seek(cout, HEADR+textsize+datsize+symsize, 0);
+	elf64shdr(putl, putll, 0, 0, 0, 0,
+		0, 0, 0, 0, 0, 0);
 	elf64shdr(putl, putll, Stitext, Progbits, Salloc|Sexec, INITTEXT,
-		HEADR, textsize, 0, 0, 0x10000, 0);
+		HEADR, textsize, 0, 0, INITRND, 0);
 	elf64shdr(putl, putll, Stidata, Progbits, Salloc|Swrite, INITDAT,
-		HEADR+textsize, datsize, 0, 0, 0x10000, 0);
+		HEADR+textsize, datsize, 0, 0, INITRND, 0);
 	elf64shdr(putl, putll, Stistrtab, Strtab, 1 << 5, 0,
-		HEADR+textsize+datsize+symsize+3*Shdr64sz, 14, 0, 0, 1, 0);
+		HEADR+textsize+datsize+symsize+4*Shdr64sz, 22, 0, 0, 1, 0);
 	elfstrtab();
 }
 
@@ -240,8 +244,8 @@ elf64(int mach, int bo, int addpsects, void (*putpsects)(Putl))
 	putw(3 + addpsects);		/* # of Phdrs */
 	putw(Shdr64sz);
 	if(debug['S']){
-		putw(3);		/* # of Shdrs */
-		putw(2);		/* Shdr table index */
+		putw(4);		/* # of Shdrs */
+		putw(3);		/* Shdr table index */
 	}else{
 		putw(0);
 		putw(0);

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.