Date: Thu, 19 Jun 1997 01:39:51 -0400 (EDT) From: Luoqi Chen <luoqi@sabrina.watermarkgroup.com> To: hackers@FreeBSD.Org Subject: ld -T bug Message-ID: <199706190539.BAA11739@sabrina.watermarkgroup.com>
next in thread | raw e-mail | index | archive | help
I tried to link an executable at a start address other than the default, with dynamical binding, by passing -T flag to ld. Though I won't be able to run it with exec system call, but I could mmap it in a loader program and jump to the start address. The link was successful, but it seemed that ld had written RSS section at the wrong offset in the executable file, it was written as if the start address was still the default. So ld.so won't see them at expected location and results in a segmentation fault. This problem goes away when binding statically (e.g. building the kernel) as there is no RSS section. I have attached a fix for this problem. Could anyone commit this to the CVS tree? Thanks. Index: rrs.c =================================================================== RCS file: /fun/cvs/src/gnu/usr.bin/ld/rrs.c,v retrieving revision 1.17 diff -u -r1.17 rrs.c --- rrs.c 1996/10/01 01:22:35 1.17 +++ rrs.c 1997/06/19 05:08:25 @@ -947,7 +947,11 @@ if (rrs_section_type == RRS_NONE) return; +#if 0 pos = rrs_data_start + (N_DATOFF(outheader) - DATA_START(outheader)); +#else + pos = N_DATOFF(outheader); +#endif if (fseek(outstream, pos, SEEK_SET) != 0) err(1, "write_rrs_data: fseek"); @@ -996,7 +1000,11 @@ if (rrs_section_type == RRS_PARTIAL) return; +#if 0 pos = rrs_text_start + (N_TXTOFF(outheader) - TEXT_START(outheader)); +#else + pos = rrs_text_start + (N_TXTOFF(outheader) - text_start); +#endif if (fseek(outstream, pos, SEEK_SET) != 0) err(1, "write_rrs_text: fseek");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199706190539.BAA11739>
