From owner-freebsd-mips@freebsd.org Thu Feb 8 11:01:54 2018 Return-Path: Delivered-To: freebsd-mips@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 56955F195DD for ; Thu, 8 Feb 2018 11:01:54 +0000 (UTC) (envelope-from yamori813@yahoo.co.jp) Received: from nh603-vm1.bullet.mail.ssk.yahoo.co.jp (nh603-vm1.bullet.mail.ssk.yahoo.co.jp [182.22.90.42]) by mx1.freebsd.org (Postfix) with SMTP id 6A56881291 for ; Thu, 8 Feb 2018 11:01:53 +0000 (UTC) (envelope-from yamori813@yahoo.co.jp) Received: from [182.22.66.103] by nh603.bullet.mail.ssk.yahoo.co.jp with NNFMP; 08 Feb 2018 10:58:59 -0000 Received: from [182.22.91.132] by t601.bullet.mail.ssk.yahoo.co.jp with NNFMP; 08 Feb 2018 10:58:59 -0000 Received: from [127.0.0.1] by omp605.mail.ssk.yahoo.co.jp with NNFMP; 08 Feb 2018 10:58:59 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 662423.51717.bm@omp605.mail.ssk.yahoo.co.jp Received: (qmail 27222 invoked by uid 60001); 8 Feb 2018 10:58:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1518087539; bh=bMMTOqRzk999PoduySUd5UoY2ThSejhXUhCljbDhW9k=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:X-YMail-JAS:References:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=Dhq0U++6yCQgPUUeGI5zP9h6DqzzMFj6qdwh5x1qjwzQwDW+pDHu+JhFd5R+gGw7xFKYkYS6FrUX8f6DUl0BFsk6kQi6o9QrhAfQGDsG6gmdroPNyBwoUKsnNcOcSInHVHQvE3VNNqAY8e6hTabj9/GlKdpsdsmXrgeWVsRtxjU= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Message-ID:X-YMail-OSG:Received:X-Mailer:X-YMail-JAS:References:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=uAai8R8A5hRnm2GoOc3rw9vqAepWRGgLB4RcdRujNJDURCsZXGSFYHa9CTXYhW8aJGyFbSc7NfEjNAyX+S58mPTDVGeMkiOA5HTzEUogNL+yS4cXSwzsFuB1aowWplOmnzyPIJi43LJ2+rvrghXb4NC/zoQPx2/nXKH26kGelEs=; Message-ID: <406460.12451.qm@web101716.mail.ssk.yahoo.co.jp> X-YMail-OSG: y28OW58VM1mZFlWiDJUPry3ZW_T3V0s.TPrLEdRYzdt5mJk7iJwiWwZVGh1RBnzNUTb4MK0O951gYnNvJf64HQJdoWEXH3ILOBTHJ5nO42mLKo2sbm9vbpKGLtX9tZxDHF0yV_SOzeoqmaCdt6tkz07KLL0B6XJ3afShuHvjO9V4T6l35xtnM5Ci5__uhG3.XYDWgliiPvepZeVov3w7zS.ezrVYkyk9ET0I4JWX2XCX7wcdVxWRpHuJO19eNc3L8XbuBBVLARjXvIGm0Bod5bcr0eXox.nS913kreYwJceLhW.YIEdqmGJV1WIHF1ezT33b02oTfLrvw9FM2b4Fxclyi3hXkGDP5zl4XgM.8eI7r8_J3MBwBue7jLonGfL.ETCXHLu7kxUIBS5Alhmgbvv9RhkYGxoVS5mrFAzhJEQr_n1oNcJ9H_r8sDKXUZVuk_p7tzKr9Xau3Nj2zjV4gYakp83YFy43odNfWjrCjKH5gYRIdi37iNJ6oJDdxQEbRU21zh80dvD_g4_9c8WQGY9jB5mBB5wizv3339ecGYRZDddjk5WrnO25qb7_TweTY5gkEK.LjUt1WyDFDDDDUG.anbsWuqtfioxLS8d9Wd.I Received: from [203.165.91.75] by web101716.mail.ssk.yahoo.co.jp via HTTP; Thu, 08 Feb 2018 19:58:57 JST X-Mailer: YahooMailWebService/0.8.111_74 X-YMail-JAS: FmVERz8VM1njK..EPdd6Mm5wW56CNXIrEthgo1QxSxxsVueVe9IoMVrTNHpbqHLRqkFKrRp1AJ.y37KHUZNlzL3e_03yLKXb.ROSwUg0G7BhJEW3PI.GXl1GZUL3ZwWxobZ5 References: <87596.64393.qm@web101718.mail.ssk.yahoo.co.jp> <4510846.CbLV3ucMtE@ralph.baldwin.cx> Date: Thu, 8 Feb 2018 19:58:57 +0900 (JST) From: Mori Hiroki Reply-To: Mori Hiroki Subject: Re: kld not work on Atheros To: John Baldwin , Adrian Chadd Cc: Michael Zhilin , "freebsd-mips@freebsd.org" In-Reply-To: <4510846.CbLV3ucMtE@ralph.baldwin.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Feb 2018 11:01:54 -0000 Hi=0A=0ASorry too late reply.=0A=0AI try to head code now. Work fine. Thank= s.=0A=0AHiroki Mori=0A=0A=0A----- Original Message -----=0A> From: John Bal= dwin =0A> To: Adrian Chadd =0A> Cc: Mi= chael Zhilin ; Mori Hiroki ; "free= bsd-mips@freebsd.org" =0A> Date: 2018/2/2, Fri 05= :06=0A> Subject: Re: kld not work on Atheros=0A> =0A> On Wednesday, January= 31, 2018 02:12:42 PM Adrian Chadd wrote:=0A>> Hi,=0A>> =0A>> Bump - do I= just put in an #ifdef MIPS around this workaround for now,=0A>> or what's= the cleaner solution? :)=0A> =0A> Cleaner solution is to not load reltabs = or relatabs for sections that don't=0A> have SHF_ALLOC set.=A0 That is, ear= lier in load_elf_obj.c (in loader) and=0A> in link_elf_obj.c when looping o= ver SHT_RELTAB and SHT_RELTABA sections,=0A> ignore relocation tables whose= associated section doesn't have SHF_ALLOC=0A> set.=0A> =0A> Try this (unte= sted):=0A> =0A> diff --git a/stand/common/load_elf_obj.c b/stand/common/loa= d_elf_obj.c=0A> index b58dde0dfbf8..4c893e17a5b1 100644=0A> --- a/stand/com= mon/load_elf_obj.c=0A> +++ b/stand/common/load_elf_obj.c=0A> @@ -282,6 +282= ,8 @@ __elfN(obj_loadimage)(struct preloaded_file *fp, elf_file_t =0A> ef, = u_int64_t off)=0A> =A0=A0=A0 =A0=A0=A0 switch (shdr[i].sh_type) {=0A> =A0= =A0=A0 =A0=A0=A0 case SHT_REL:=0A> =A0=A0=A0 =A0=A0=A0 case SHT_RELA:=0A> += =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 if ((shdr[shdr[i].sh_info].sh_flags & SHF_ALL= OC) =3D=3D 0)=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 break;=0A> =A0= =A0=A0 =A0=A0=A0 =A0=A0=A0 lastaddr =3D roundup(lastaddr, shdr[i].sh_addral= ign);=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 shdr[i].sh_addr =3D (Elf_Addr)lasta= ddr;=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 lastaddr +=3D shdr[i].sh_size;=0A> d= iff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c=0A> index 448= d5b9c08a5..0bcec40822e1 100644=0A> --- a/sys/kern/link_elf_obj.c=0A> +++ b/= sys/kern/link_elf_obj.c=0A> @@ -272,9 +272,17 @@ link_elf_link_preload(link= er_class_t cls, const char =0A> *filename,=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0= =A0 symstrindex =3D shdr[i].sh_link;=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 brea= k;=0A> =A0=A0=A0 =A0=A0=A0 case SHT_REL:=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0= /*=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 * Ignore relocation tables for sect= ions not=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 * loaded by the loader.=0A> += =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 */=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 if (sh= dr[shdr[i].sh_info].sh_addr =3D=3D 0)=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 = =A0=A0=A0 break;=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 ef->nreltab++;=0A> =A0= =A0=A0 =A0=A0=A0 =A0=A0=A0 break;=0A> =A0=A0=A0 =A0=A0=A0 case SHT_RELA:=0A= > +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 if (shdr[shdr[i].sh_info].sh_addr =3D=3D 0= )=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 break;=0A> =A0=A0=A0 =A0=A0= =A0 =A0=A0=A0 ef->nrelatab++;=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 break;=0A> = =A0=A0=A0 =A0=A0=A0 }=0A> @@ -398,12 +406,16 @@ link_elf_link_preload(linke= r_class_t cls, const char =0A> *filename,=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0= pb++;=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 break;=0A> =A0=A0=A0 =A0=A0=A0 cas= e SHT_REL:=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 if (shdr[shdr[i].sh_info].sh_= addr =3D=3D 0)=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 break;=0A> =A0= =A0=A0 =A0=A0=A0 =A0=A0=A0 ef->reltab[rl].rel =3D (Elf_Rel *)shdr[i].sh_add= r;=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 ef->reltab[rl].nrel =3D shdr[i].sh_siz= e / sizeof(Elf_Rel);=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 ef->reltab[rl].sec = =3D shdr[i].sh_info;=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 rl++;=0A> =A0=A0=A0 = =A0=A0=A0 =A0=A0=A0 break;=0A> =A0=A0=A0 =A0=A0=A0 case SHT_RELA:=0A> +=A0= =A0=A0 =A0=A0=A0 =A0=A0=A0 if (shdr[shdr[i].sh_info].sh_addr =3D=3D 0)=0A> = +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 break;=0A> =A0=A0=A0 =A0=A0=A0 =A0= =A0=A0 ef->relatab[ra].rela =3D (Elf_Rela *)shdr[i].sh_addr;=0A> =A0=A0=A0 = =A0=A0=A0 =A0=A0=A0 ef->relatab[ra].nrela =3D=0A> =A0=A0=A0 =A0=A0=A0 =A0= =A0=A0 =A0 =A0 shdr[i].sh_size / sizeof(Elf_Rela);=0A> @@ -620,9 +632,17 @@= link_elf_load_file(linker_class_t cls, const char =0A> *filename,=0A> =A0= =A0=A0 =A0=A0=A0 =A0=A0=A0 symstrindex =3D shdr[i].sh_link;=0A> =A0=A0=A0 = =A0=A0=A0 =A0=A0=A0 break;=0A> =A0=A0=A0 =A0=A0=A0 case SHT_REL:=0A> +=A0= =A0=A0 =A0=A0=A0 =A0=A0=A0 /*=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 * Ignore = relocation tables for unallocated=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 * sec= tions.=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 */=0A> +=A0=A0=A0 =A0=A0=A0 =A0= =A0=A0 if ((shdr[shdr[i].sh_info].sh_flags & SHF_ALLOC) =3D=3D 0)=0A> +=A0= =A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 break;=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0= =A0 ef->nreltab++;=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 break;=0A> =A0=A0=A0 = =A0=A0=A0 case SHT_RELA:=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 if ((shdr[shdr[= i].sh_info].sh_flags & SHF_ALLOC) =3D=3D 0)=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0= =A0 =A0=A0=A0 break;=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 ef->nrelatab++;=0A> = =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 break;=0A> =A0=A0=A0 =A0=A0=A0 case SHT_STRTA= B:=0A> @@ -880,6 +900,8 @@ link_elf_load_file(linker_class_t cls, const cha= r *filename,=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 pb++;=0A> =A0=A0=A0 =A0=A0= =A0 =A0=A0=A0 break;=0A> =A0=A0=A0 =A0=A0=A0 case SHT_REL:=0A> +=A0=A0=A0 = =A0=A0=A0 =A0=A0=A0 if ((shdr[shdr[i].sh_info].sh_flags & SHF_ALLOC) =3D=3D= 0)=0A> +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 break;=0A> =A0=A0=A0 =A0= =A0=A0 =A0=A0=A0 ef->reltab[rl].rel =3D malloc(shdr[i].sh_size, M_LINKER,= =0A> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0 =A0 M_WAITOK);=0A> =A0=A0=A0 =A0=A0= =A0 =A0=A0=A0 ef->reltab[rl].nrel =3D shdr[i].sh_size / sizeof(Elf_Rel);=0A= > @@ -898,6 +920,8 @@ link_elf_load_file(linker_class_t cls, const char *fi= lename,=0A> =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 rl++;=0A> =A0=A0=A0 =A0=A0=A0 =A0= =A0=A0 break;=0A> =A0=A0=A0 =A0=A0=A0 case SHT_RELA:=0A> +=A0=A0=A0 =A0=A0= =A0 =A0=A0=A0 if ((shdr[shdr[i].sh_info].sh_flags & SHF_ALLOC) =3D=3D 0)=0A= > +=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 break;=0A> =A0=A0=A0 =A0=A0=A0 = =A0=A0=A0 ef->relatab[ra].rela =3D malloc(shdr[i].sh_size, M_LINKER,=0A> = =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0 =A0 M_WAITOK);=0A> =A0=A0=A0 =A0=A0=A0 = =A0=A0=A0 ef->relatab[ra].nrela =3D=0A> =0A> -- =0A> John Baldwin=0A> From owner-freebsd-mips@freebsd.org Sat Feb 10 19:50:34 2018 Return-Path: Delivered-To: freebsd-mips@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CCADEF18A11 for ; Sat, 10 Feb 2018 19:50:34 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-wm0-x22c.google.com (mail-wm0-x22c.google.com [IPv6:2a00:1450:400c:c09::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 574056EEA7; Sat, 10 Feb 2018 19:50:34 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: by mail-wm0-x22c.google.com with SMTP id i186so3121506wmi.4; Sat, 10 Feb 2018 11:50:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=9XyhxY7LuZ2xCjcqbckYqgoE7KBaZL0IiqoQ3OBfs3k=; b=XUsFg+FZFIOS/baBCbS4S6bfJJBvtto3kkEgyc7lcu7gqjBoppHJ3yNgUmNSdTTfQq ifmgtMcsUhXltRwaThGOBDIX8D0h5uS/3iTA0SInSYQs3kc4emZod9RTALwi5paQXKeZ u/7h8riMGDAXqGm64ct9Gx+HGCRM19xgysoBQq4uXDtPUD4nCPh5xMjYKFZG3Gj1v08a q58pYOjL3a4ysn0MoD//fIUqrpUBdYCQc2BZ5ul3USpNbM2qKrVTrlkaVldvlGShCLp1 KWbhWCSsbe1Jk00fF1jRN3vK6bI4U6tl/dzSPh17YecZR0pSnqgu51VoYi4MVg/GvTdr 98pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=9XyhxY7LuZ2xCjcqbckYqgoE7KBaZL0IiqoQ3OBfs3k=; b=JLtSOQUOcxy1bGg1XEab6I02Jpg0YJaJwASVzgXTLDyXEO62EdLR5mtkZEEcFCIyzz GFLfZ0ykn1cRn7HSC/iKqaa5nIWX7SQBDY29T/asv3Yd61GG8mLfh25rmZCwgpxlHwlg 7hFKTTmqS/UwRxKKFEb8ISVGQIQYDvzCnL1DeQRSdNPWGvQ8iCMlMVnQ27lF2jJIOTFM JOcsJ32nsATr+NGRkTWpjmpmOucMN6RP/QZ7gYhWbrOvspzCx+WrdexoJxM3qLmF0G5V fC6loEFndN2cjlNJSHJvRC2w2qZXLMxDTHUn59Tq6imdI+wCR/PvmINkGgJfKVYaTJ0Q nAyw== X-Gm-Message-State: APf1xPAtSmpvcmtCwwigMDL10wglwnrP6+1HQajMCbgxKIMTkJ4gz8Oh jNeKJlpK1JJpp9RMPz1AS73JbBa1hgQXKFI70QzucQ== X-Google-Smtp-Source: AH8x2240pMX8IHfRzGfJI5kwtJemcDUlDUcYBBJf7VdDJ39YoNuWqoj321Mp6mV9Z/x802dLIWupCaWqOA/X4bb8lrA= X-Received: by 10.28.71.198 with SMTP id m67mr5510481wmi.40.1518292233191; Sat, 10 Feb 2018 11:50:33 -0800 (PST) MIME-Version: 1.0 Sender: adrian.chadd@gmail.com Received: by 10.28.131.8 with HTTP; Sat, 10 Feb 2018 11:50:32 -0800 (PST) In-Reply-To: <406460.12451.qm@web101716.mail.ssk.yahoo.co.jp> References: <87596.64393.qm@web101718.mail.ssk.yahoo.co.jp> <4510846.CbLV3ucMtE@ralph.baldwin.cx> <406460.12451.qm@web101716.mail.ssk.yahoo.co.jp> From: Adrian Chadd Date: Sat, 10 Feb 2018 11:50:32 -0800 X-Google-Sender-Auth: Ul-nCSJSvVXdL4Q_-pdFhTPMJGI Message-ID: Subject: Re: kld not work on Atheros To: Mori Hiroki Cc: John Baldwin , Michael Zhilin , "freebsd-mips@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Feb 2018 19:50:35 -0000 hi, Mori - did you try John's patch and it worked ok? -a On 8 February 2018 at 02:58, Mori Hiroki wrote: > Hi > > Sorry too late reply. > > I try to head code now. Work fine. Thanks. > > Hiroki Mori > > > ----- Original Message ----- >> From: John Baldwin >> To: Adrian Chadd >> Cc: Michael Zhilin ; Mori Hiroki ; "freebsd-mips@freebsd.org" >> Date: 2018/2/2, Fri 05:06 >> Subject: Re: kld not work on Atheros >> >> On Wednesday, January 31, 2018 02:12:42 PM Adrian Chadd wrote: >>> Hi, >>> >>> Bump - do I just put in an #ifdef MIPS around this workaround for now, >>> or what's the cleaner solution? :) >> >> Cleaner solution is to not load reltabs or relatabs for sections that don't >> have SHF_ALLOC set. That is, earlier in load_elf_obj.c (in loader) and >> in link_elf_obj.c when looping over SHT_RELTAB and SHT_RELTABA sections, >> ignore relocation tables whose associated section doesn't have SHF_ALLOC >> set. >> >> Try this (untested): >> >> diff --git a/stand/common/load_elf_obj.c b/stand/common/load_elf_obj.c >> index b58dde0dfbf8..4c893e17a5b1 100644 >> --- a/stand/common/load_elf_obj.c >> +++ b/stand/common/load_elf_obj.c >> @@ -282,6 +282,8 @@ __elfN(obj_loadimage)(struct preloaded_file *fp, elf_file_t >> ef, u_int64_t off) >> switch (shdr[i].sh_type) { >> case SHT_REL: >> case SHT_RELA: >> + if ((shdr[shdr[i].sh_info].sh_flags & SHF_ALLOC) == 0) >> + break; >> lastaddr = roundup(lastaddr, shdr[i].sh_addralign); >> shdr[i].sh_addr = (Elf_Addr)lastaddr; >> lastaddr += shdr[i].sh_size; >> diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c >> index 448d5b9c08a5..0bcec40822e1 100644 >> --- a/sys/kern/link_elf_obj.c >> +++ b/sys/kern/link_elf_obj.c >> @@ -272,9 +272,17 @@ link_elf_link_preload(linker_class_t cls, const char >> *filename, >> symstrindex = shdr[i].sh_link; >> break; >> case SHT_REL: >> + /* >> + * Ignore relocation tables for sections not >> + * loaded by the loader. >> + */ >> + if (shdr[shdr[i].sh_info].sh_addr == 0) >> + break; >> ef->nreltab++; >> break; >> case SHT_RELA: >> + if (shdr[shdr[i].sh_info].sh_addr == 0) >> + break; >> ef->nrelatab++; >> break; >> } >> @@ -398,12 +406,16 @@ link_elf_link_preload(linker_class_t cls, const char >> *filename, >> pb++; >> break; >> case SHT_REL: >> + if (shdr[shdr[i].sh_info].sh_addr == 0) >> + break; >> ef->reltab[rl].rel = (Elf_Rel *)shdr[i].sh_addr; >> ef->reltab[rl].nrel = shdr[i].sh_size / sizeof(Elf_Rel); >> ef->reltab[rl].sec = shdr[i].sh_info; >> rl++; >> break; >> case SHT_RELA: >> + if (shdr[shdr[i].sh_info].sh_addr == 0) >> + break; >> ef->relatab[ra].rela = (Elf_Rela *)shdr[i].sh_addr; >> ef->relatab[ra].nrela = >> shdr[i].sh_size / sizeof(Elf_Rela); >> @@ -620,9 +632,17 @@ link_elf_load_file(linker_class_t cls, const char >> *filename, >> symstrindex = shdr[i].sh_link; >> break; >> case SHT_REL: >> + /* >> + * Ignore relocation tables for unallocated >> + * sections. >> + */ >> + if ((shdr[shdr[i].sh_info].sh_flags & SHF_ALLOC) == 0) >> + break; >> ef->nreltab++; >> break; >> case SHT_RELA: >> + if ((shdr[shdr[i].sh_info].sh_flags & SHF_ALLOC) == 0) >> + break; >> ef->nrelatab++; >> break; >> case SHT_STRTAB: >> @@ -880,6 +900,8 @@ link_elf_load_file(linker_class_t cls, const char *filename, >> pb++; >> break; >> case SHT_REL: >> + if ((shdr[shdr[i].sh_info].sh_flags & SHF_ALLOC) == 0) >> + break; >> ef->reltab[rl].rel = malloc(shdr[i].sh_size, M_LINKER, >> M_WAITOK); >> ef->reltab[rl].nrel = shdr[i].sh_size / sizeof(Elf_Rel); >> @@ -898,6 +920,8 @@ link_elf_load_file(linker_class_t cls, const char *filename, >> rl++; >> break; >> case SHT_RELA: >> + if ((shdr[shdr[i].sh_info].sh_flags & SHF_ALLOC) == 0) >> + break; >> ef->relatab[ra].rela = malloc(shdr[i].sh_size, M_LINKER, >> M_WAITOK); >> ef->relatab[ra].nrela = >> >> -- >> John Baldwin >>