Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Feb 2018 17:27:34 +0900 (JST)
From:      Mori Hiroki <yamori813@yahoo.co.jp>
To:        Adrian Chadd <adrian@freebsd.org>
Cc:        John Baldwin <jhb@freebsd.org>, Michael Zhilin <mizhka@gmail.com>, "freebsd-mips@freebsd.org" <freebsd-mips@freebsd.org>
Subject:   Re: kld not work on Atheros
Message-ID:  <879776.28314.qm@web101719.mail.ssk.yahoo.co.jp>
In-Reply-To: <CAJ-Vmo=YAgr1zcHm4jVO7qjPpYM71W_xgk8gMArfW5NMCGciLQ@mail.gmail.com>
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> <406460.12451.qm@web101716.mail.ssk.yahoo.co.jp> <CAJ-Vmo=YAgr1zcHm4jVO7qjPpYM71W_xgk8gMArfW5NMCGciLQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi.=0A=0AI find this commit and try to head code.=0A=0Ahttps://svnweb.freeb=
sd.org/base?view=3Drevision&revision=3D328911=0A=0A=0Ahead code is kld work=
 fine now.=0A=0AHiroki Mori=0A=0A=0A----- Original Message -----=0A> From: =
Adrian Chadd <adrian@freebsd.org>=0A> To: Mori Hiroki <yamori813@yahoo.co.j=
p>=0A> Cc: John Baldwin <jhb@freebsd.org>; Michael Zhilin <mizhka@gmail.com=
>; "freebsd-mips@freebsd.org" <freebsd-mips@freebsd.org>=0A> Date: 2018/2/1=
1, Sun 04:50=0A> Subject: Re: kld not work on Atheros=0A> =0A> hi,=0A> =0A>=
 Mori - did you try John's patch and it worked ok?=0A> =0A> =0A> -a=0A> =0A=
> =0A> On 8 February 2018 at 02:58, Mori Hiroki <yamori813@yahoo.co.jp> wro=
te:=0A>>  Hi=0A>> =0A>>  Sorry too late reply.=0A>> =0A>>  I try to head co=
de now. Work fine. Thanks.=0A>> =0A>>  Hiroki Mori=0A>> =0A>> =0A>>  ----- =
Original Message -----=0A>>>  From: John Baldwin <jhb@freebsd.org>=0A>>>  T=
o: Adrian Chadd <adrian@freebsd.org>=0A>>>  Cc: Michael Zhilin <mizhka@gmai=
l.com>; Mori Hiroki =0A> <yamori813@yahoo.co.jp>; "freebsd-mips@freebsd.org=
" =0A> <freebsd-mips@freebsd.org>=0A>>>  Date: 2018/2/2, Fri 05:06=0A>>>  S=
ubject: Re: kld not work on Atheros=0A>>> =0A>>>  On Wednesday, January 31,=
 2018 02:12:42 PM Adrian Chadd wrote:=0A>>>> =A0 Hi,=0A>>>> =0A>>>> =A0 Bum=
p - do I just put in an #ifdef MIPS around this workaround for =0A> now,=0A=
>>>> =A0 or what's the cleaner solution? :)=0A>>> =0A>>>  Cleaner solution =
is to not load reltabs or relatabs for sections that =0A> don't=0A>>>  have=
 SHF_ALLOC set.=A0 That is, earlier in load_elf_obj.c (in loader) and=0A>>>=
  in link_elf_obj.c when looping over SHT_RELTAB and SHT_RELTABA =0A> secti=
ons,=0A>>>  ignore relocation tables whose associated section doesn't have =
=0A> SHF_ALLOC=0A>>>  set.=0A>>> =0A>>>  Try this (untested):=0A>>> =0A>>> =
 diff --git a/stand/common/load_elf_obj.c b/stand/common/load_elf_obj.c=0A>=
>>  index b58dde0dfbf8..4c893e17a5b1 100644=0A>>>  --- a/stand/common/load_=
elf_obj.c=0A>>>  +++ b/stand/common/load_elf_obj.c=0A>>>  @@ -282,6 +282,8 =
@@ __elfN(obj_loadimage)(struct preloaded_file *fp, =0A> elf_file_t=0A>>>  =
ef, u_int64_t off)=0A>>> =A0 =A0 =A0 =A0  switch (shdr[i].sh_type) {=0A>>> =
=A0 =A0 =A0 =A0  case SHT_REL:=0A>>> =A0 =A0 =A0 =A0  case SHT_RELA:=0A>>> =
 +=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 break;=0A>>> =A0 =A0 =A0 =
=A0 =A0 =A0  lastaddr =3D roundup(lastaddr, shdr[i].sh_addralign);=0A>>> =
=A0 =A0 =A0 =A0 =A0 =A0  shdr[i].sh_addr =3D (Elf_Addr)lastaddr;=0A>>> =A0 =
=A0 =A0 =A0 =A0 =A0  lastaddr +=3D shdr[i].sh_size;=0A>>>  diff --git a/sys=
/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c=0A>>>  index 448d5b9c08a5..0=
bcec40822e1 100644=0A>>>  --- a/sys/kern/link_elf_obj.c=0A>>>  +++ b/sys/ke=
rn/link_elf_obj.c=0A>>>  @@ -272,9 +272,17 @@ link_elf_link_preload(linker_=
class_t cls, const =0A> char=0A>>>  *filename,=0A>>> =A0 =A0 =A0 =A0 =A0 =
=A0  symstrindex =3D shdr[i].sh_link;=0A>>> =A0 =A0 =A0 =A0 =A0 =A0  break;=
=0A>>> =A0 =A0 =A0 =A0  case SHT_REL:=0A>>>  +=A0 =A0 =A0 =A0 =A0 =A0 /*=0A=
>>>  +=A0 =A0 =A0 =A0 =A0 =A0  * Ignore relocation tables for sections not=
=0A>>>  +=A0 =A0 =A0 =A0 =A0 =A0  * loaded by the loader.=0A>>>  +=A0 =A0 =
=A0 =A0 =A0 =A0  */=0A>>>  +=A0 =A0 =A0 =A0 =A0 =A0 if (shdr[shdr[i].sh_inf=
o].sh_addr =3D=3D 0)=0A>>>  +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;=0A>>> =
=A0 =A0 =A0 =A0 =A0 =A0  ef->nreltab++;=0A>>> =A0 =A0 =A0 =A0 =A0 =A0  brea=
k;=0A>>> =A0 =A0 =A0 =A0  case SHT_RELA:=0A>>>  +=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 break;=0A>>> =A0 =A0 =A0 =A0 =A0 =A0  ef->nrelatab++;=0A>>> =A0 =A0=
 =A0 =A0 =A0 =A0  break;=0A>>> =A0 =A0 =A0 =A0  }=0A>>>  @@ -398,12 +406,16=
 @@ link_elf_link_preload(linker_class_t cls, const =0A> char=0A>>>  *filen=
ame,=0A>>> =A0 =A0 =A0 =A0 =A0 =A0  pb++;=0A>>> =A0 =A0 =A0 =A0 =A0 =A0  br=
eak;=0A>>> =A0 =A0 =A0 =A0  case SHT_REL:=0A>>>  +=A0 =A0 =A0 =A0 =A0 =A0 i=
f (shdr[shdr[i].sh_info].sh_addr =3D=3D 0)=0A>>>  +=A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 break;=0A>>> =A0 =A0 =A0 =A0 =A0 =A0  ef->reltab[rl].rel =3D (Elf_R=
el *)shdr[i].sh_addr;=0A>>> =A0 =A0 =A0 =A0 =A0 =A0  ef->reltab[rl].nrel =
=3D shdr[i].sh_size / sizeof(Elf_Rel);=0A>>> =A0 =A0 =A0 =A0 =A0 =A0  ef->r=
eltab[rl].sec =3D shdr[i].sh_info;=0A>>> =A0 =A0 =A0 =A0 =A0 =A0  rl++;=0A>=
>> =A0 =A0 =A0 =A0 =A0 =A0  break;=0A>>> =A0 =A0 =A0 =A0  case SHT_RELA:=0A=
>>>  +=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 break;=0A>>> =A0 =A0 =A0 =A0 =A0 =
=A0  ef->relatab[ra].rela =3D (Elf_Rela *)shdr[i].sh_addr;=0A>>> =A0 =A0 =
=A0 =A0 =A0 =A0  ef->relatab[ra].nrela =3D=0A>>> =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0  shdr[i].sh_size / sizeof(Elf_Rela);=0A>>>  @@ -620,9 +632,17 @@ li=
nk_elf_load_file(linker_class_t cls, const char=0A>>>  *filename,=0A>>> =A0=
 =A0 =A0 =A0 =A0 =A0  symstrindex =3D shdr[i].sh_link;=0A>>> =A0 =A0 =A0 =
=A0 =A0 =A0  break;=0A>>> =A0 =A0 =A0 =A0  case SHT_REL:=0A>>>  +=A0 =A0 =
=A0 =A0 =A0 =A0 /*=0A>>>  +=A0 =A0 =A0 =A0 =A0 =A0  * Ignore relocation tab=
les for unallocated=0A>>>  +=A0 =A0 =A0 =A0 =A0 =A0  * sections.=0A>>>  +=
=A0 =A0 =A0 =A0 =A0 =A0  */=0A>>>  +=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 break;=0A>>> =A0 =A0 =A0 =A0 =A0 =A0  ef->nreltab++;=0A>>> =A0 =A0=
 =A0 =A0 =A0 =A0  break;=0A>>> =A0 =A0 =A0 =A0  case SHT_RELA:=0A>>>  +=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 break;=0A>>> =A0 =A0 =A0 =A0 =
=A0 =A0  ef->nrelatab++;=0A>>> =A0 =A0 =A0 =A0 =A0 =A0  break;=0A>>> =A0 =
=A0 =A0 =A0  case SHT_STRTAB:=0A>>>  @@ -880,6 +900,8 @@ link_elf_load_file=
(linker_class_t cls, const char =0A> *filename,=0A>>> =A0 =A0 =A0 =A0 =A0 =
=A0  pb++;=0A>>> =A0 =A0 =A0 =A0 =A0 =A0  break;=0A>>> =A0 =A0 =A0 =A0  cas=
e SHT_REL:=0A>>>  +=A0 =A0 =A0 =A0 =A0 =A0 if ((shdr[shdr[i].sh_info].sh_fl=
ags & SHF_ALLOC) =3D=3D 0)=0A>>>  +=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;=
=0A>>> =A0 =A0 =A0 =A0 =A0 =A0  ef->reltab[rl].rel =3D malloc(shdr[i].sh_si=
ze, M_LINKER,=0A>>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0  M_WAITOK);=0A>>> =A0 =
=A0 =A0 =A0 =A0 =A0  ef->reltab[rl].nrel =3D shdr[i].sh_size / sizeof(Elf_R=
el);=0A>>>  @@ -898,6 +920,8 @@ link_elf_load_file(linker_class_t cls, cons=
t char =0A> *filename,=0A>>> =A0 =A0 =A0 =A0 =A0 =A0  rl++;=0A>>> =A0 =A0 =
=A0 =A0 =A0 =A0  break;=0A>>> =A0 =A0 =A0 =A0  case SHT_RELA:=0A>>>  +=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 break;=0A>>> =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  M_WAITOK);=0A>>> =A0 =A0 =A0 =A0 =A0 =A0  =
ef->relatab[ra].nrela =3D=0A>>> =0A>>>  --=0A>>>  John Baldwin=0A>>> =0A> 



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