From owner-freebsd-hackers Wed Jun 18 22:40:09 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id WAA07675 for hackers-outgoing; Wed, 18 Jun 1997 22:40:09 -0700 (PDT) Received: from sabrina.watermarkgroup.com (ppp-2.ts-1.ptn.idt.net [169.132.64.2]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id WAA07611 for ; Wed, 18 Jun 1997 22:39:56 -0700 (PDT) Received: (from luoqi@localhost) by sabrina.watermarkgroup.com (8.8.5/8.6.12) id BAA11739 for hackers@FreeBSD.Org; Thu, 19 Jun 1997 01:39:51 -0400 (EDT) Date: Thu, 19 Jun 1997 01:39:51 -0400 (EDT) From: Luoqi Chen Message-Id: <199706190539.BAA11739@sabrina.watermarkgroup.com> To: hackers@FreeBSD.Org Subject: ld -T bug Sender: owner-hackers@FreeBSD.Org X-Loop: FreeBSD.org Precedence: bulk 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");