Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Feb 2018 19:58:57 +0900 (JST)
From:      Mori Hiroki <yamori813@yahoo.co.jp>
To:        John Baldwin <jhb@freebsd.org>, Adrian Chadd <adrian@freebsd.org>
Cc:        Michael Zhilin <mizhka@gmail.com>, "freebsd-mips@freebsd.org" <freebsd-mips@freebsd.org>
Subject:   Re: kld not work on Atheros
Message-ID:  <406460.12451.qm@web101716.mail.ssk.yahoo.co.jp>
In-Reply-To: <4510846.CbLV3ucMtE@ralph.baldwin.cx>
References:  <87596.64393.qm@web101718.mail.ssk.yahoo.co.jp> <CAJ-Vmon1vRjh276Fp50GWT8BcTv31EnXD4twkVYTkSH_BFL1yQ@mail.gmail.com> <CAJ-Vmonzu1%2BrxUkW2bL-7nUPyYeY6aHjP1vYPT8gBN7iTmu3dQ@mail.gmail.com> <4510846.CbLV3ucMtE@ralph.baldwin.cx>

next in thread | previous in thread | raw e-mail | index | archive | help
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 <jhb@freebsd.org>=0A> To: Adrian Chadd <adrian@freebsd.org>=0A> Cc: Mi=
chael Zhilin <mizhka@gmail.com>; Mori Hiroki <yamori813@yahoo.co.jp>; "free=
bsd-mips@freebsd.org" <freebsd-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> 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?406460.12451.qm>