Re: [PATCH] LoongArch: Disable module from accessing external data directly

From: Xi Ruoyao
Date: Wed Nov 08 2023 - 04:26:06 EST


On Wed, 2023-11-08 at 17:20 +0800, WANG Rui wrote:
> > then the linked binary triggers a SIGBUS.  Ideally this should be
> > detected by the linker at link time, but currently the BFD linker
> > fails
> > to detect this error (FWIW this flaw is caused by a really nasty
> > method
> > for the medium code model implementation).  So to me -fno-direct-
> > access-
> > external-data is the default.  I also grepped for -fdirect-access-
> > external-data in the kernel building system but I've not found any
> > match.
> >
> > Are you using a different version of Clang, or maybe Clang has some
> > configuration-time option to make -fdirect-access-external-data the
> > default?
>
> The clang enables `direct-access-external-data` by default in PIC and
> disables it by default in no-PIC. This also applies to PIE. [1]

Oh sh*t:

xry111@nanmen2 ~ $ clang t1.c -O2 -fno-pie -no-pie
xry111@nanmen2 ~ $ ./a.out
Bus error (core dumped)

I'll consider it a Clang bug then.

--
Xi Ruoyao <xry111@xxxxxxxxxxx>
School of Aerospace Science and Technology, Xidian University