Message ID | 1458164602-16983-6-git-send-email-thomas.petazzoni@free-electrons.com |
---|---|
State | Superseded |
Headers | show |
On 03/16/16 22:43, Thomas Petazzoni wrote: > As explained by Waldemar, enabling DOPIC in uClibc will lead to the > creation of a Position Independent library. In turn, this will cause > elf2flt to generate a "Has-PIC-GOT" flat binary, which doesn't work on > ARM. In fact, elf2flt on ARM really except to have non-PIC code as ^^^^^^expects > input, so we must disable DOPIC in the uClibc configuration. > > Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> > --- > package/uclibc/uclibc.mk | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/package/uclibc/uclibc.mk b/package/uclibc/uclibc.mk > index ce706e0..d11c103 100644 > --- a/package/uclibc/uclibc.mk > +++ b/package/uclibc/uclibc.mk > @@ -94,6 +94,14 @@ define UCLIBC_ARM_THUMB_CONFIG > endef > endif > > +ifeq ($(UCLIBC_TARGET_ARCH),arm) > +ifeq ($(BR2_USE_MMU),) If elf2flt is the issue, wouldn't it make more sense to check for BINFMT_FLAT? Also, is it really only for arm that this issue exists? Custom xtensa is the only other one for which we build an internal toolchain, but I don't know if anybody ever tests it... Regards, Arnout > +define UCLIBC_ARM_NOMMU > + $(call KCONFIG_DISABLE_OPT,DOPIC,$(@D)/.config) > +endef > +endif > +endif > + > ifeq ($(BR2_UCLIBC_ARM_BX),y) > define UCLIBC_ARM_BX_CONFIG > $(call KCONFIG_ENABLE_OPT,USE_BX,$(@D)/.config) > @@ -378,6 +386,7 @@ define UCLIBC_KCONFIG_FIXUP_CMDS > $(UCLIBC_ARM_ABI_CONFIG) > $(UCLIBC_ARM_THUMB_CONFIG) > $(UCLIBC_ARM_BX_CONFIG) > + $(UCLIBC_ARM_NOMMU) > $(UCLIBC_MIPS_ABI_CONFIG) > $(UCLIBC_MIPS_ISA_CONFIG) > $(UCLIBC_SH_TYPE_CONFIG) >
Hello, On Thu, 17 Mar 2016 00:09:05 +0100, Arnout Vandecappelle wrote: > > +ifeq ($(UCLIBC_TARGET_ARCH),arm) > > +ifeq ($(BR2_USE_MMU),) > > If elf2flt is the issue, wouldn't it make more sense to check for BINFMT_FLAT? OK. At this point, on ARM BR2_USE_MMU disabled or BINFMT_FLAT=y is equivalent. But right, it's a elf2flt related issue, so testing BINFMT_FLAT makes more sense. > Also, is it really only for arm that this issue exists? Custom xtensa is the > only other one for which we build an internal toolchain, but I don't know if > anybody ever tests it... I have no idea if Xtensa noMMU has ever been tested, whether it uses FLAT or FDPIC, etc. Could we leave this up to people interested in Xtensa ? Or alternatively, remove noMMU Xtensa support altogether. I'm Cc'ing Max to see if he knows what the status of noMMU Xtensa is. Thanks! Thomas
On Thu, Mar 17, 2016 at 11:06 AM, Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote: > Hello, > > On Thu, 17 Mar 2016 00:09:05 +0100, Arnout Vandecappelle wrote: > >> > +ifeq ($(UCLIBC_TARGET_ARCH),arm) >> > +ifeq ($(BR2_USE_MMU),) >> >> If elf2flt is the issue, wouldn't it make more sense to check for BINFMT_FLAT? > > OK. At this point, on ARM BR2_USE_MMU disabled or BINFMT_FLAT=y is > equivalent. But right, it's a elf2flt related issue, so testing > BINFMT_FLAT makes more sense. > >> Also, is it really only for arm that this issue exists? Custom xtensa is the >> only other one for which we build an internal toolchain, but I don't know if >> anybody ever tests it... > > I have no idea if Xtensa noMMU has ever been tested, whether it uses > FLAT or FDPIC, etc. Could we leave this up to people interested in > Xtensa ? Or alternatively, remove noMMU Xtensa support altogether. > > I'm Cc'ing Max to see if he knows what the status of noMMU Xtensa is. I tested noMMU xtensa lightly. It uses FLAT ( https://github.com/uclinux-dev/elf2flt/commit/052ec62c087a3e9dfb62d231ee4aad253bce2f7e ), requires a patch for gcc ( https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=e3c15dbe1c4cd63d906eb67c1c607cc4fab6b329 ), and currently it defaults to generating PIC code. It appears to work with both DOPIC enabled and disabled.
Hello, On Thu, 17 Mar 2016 13:32:46 +0300, Max Filippov wrote: > > I have no idea if Xtensa noMMU has ever been tested, whether it uses > > FLAT or FDPIC, etc. Could we leave this up to people interested in > > Xtensa ? Or alternatively, remove noMMU Xtensa support altogether. > > > > I'm Cc'ing Max to see if he knows what the status of noMMU Xtensa is. > > I tested noMMU xtensa lightly. It uses FLAT > ( https://github.com/uclinux-dev/elf2flt/commit/052ec62c087a3e9dfb62d231ee4aad253bce2f7e > ), > requires a patch for gcc > ( https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=e3c15dbe1c4cd63d906eb67c1c607cc4fab6b329 > ), > and currently it defaults to generating PIC code. > It appears to work with both DOPIC enabled and disabled. Does it work within Buildroot? I think we should either have support for Xtensa noMMU and make it work, or we should remove it. From what you say, if it doesn't work already, it seems like it should be a huge work to get it working, right? Thomas
On Thu, Mar 17, 2016 at 2:00 PM, Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote: > Hello, > > On Thu, 17 Mar 2016 13:32:46 +0300, Max Filippov wrote: > >> > I have no idea if Xtensa noMMU has ever been tested, whether it uses >> > FLAT or FDPIC, etc. Could we leave this up to people interested in >> > Xtensa ? Or alternatively, remove noMMU Xtensa support altogether. >> > >> > I'm Cc'ing Max to see if he knows what the status of noMMU Xtensa is. >> >> I tested noMMU xtensa lightly. It uses FLAT >> ( https://github.com/uclinux-dev/elf2flt/commit/052ec62c087a3e9dfb62d231ee4aad253bce2f7e >> ), >> requires a patch for gcc >> ( https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=e3c15dbe1c4cd63d906eb67c1c607cc4fab6b329 >> ), >> and currently it defaults to generating PIC code. >> It appears to work with both DOPIC enabled and disabled. > > Does it work within Buildroot? I think we should either have support > for Xtensa noMMU and make it work, or we should remove it. > > From what you say, if it doesn't work already, it seems like it should > be a huge work to get it working, right? It should not, yes. Let me post the patches.
diff --git a/package/uclibc/uclibc.mk b/package/uclibc/uclibc.mk index ce706e0..d11c103 100644 --- a/package/uclibc/uclibc.mk +++ b/package/uclibc/uclibc.mk @@ -94,6 +94,14 @@ define UCLIBC_ARM_THUMB_CONFIG endef endif +ifeq ($(UCLIBC_TARGET_ARCH),arm) +ifeq ($(BR2_USE_MMU),) +define UCLIBC_ARM_NOMMU + $(call KCONFIG_DISABLE_OPT,DOPIC,$(@D)/.config) +endef +endif +endif + ifeq ($(BR2_UCLIBC_ARM_BX),y) define UCLIBC_ARM_BX_CONFIG $(call KCONFIG_ENABLE_OPT,USE_BX,$(@D)/.config) @@ -378,6 +386,7 @@ define UCLIBC_KCONFIG_FIXUP_CMDS $(UCLIBC_ARM_ABI_CONFIG) $(UCLIBC_ARM_THUMB_CONFIG) $(UCLIBC_ARM_BX_CONFIG) + $(UCLIBC_ARM_NOMMU) $(UCLIBC_MIPS_ABI_CONFIG) $(UCLIBC_MIPS_ISA_CONFIG) $(UCLIBC_SH_TYPE_CONFIG)
As explained by Waldemar, enabling DOPIC in uClibc will lead to the creation of a Position Independent library. In turn, this will cause elf2flt to generate a "Has-PIC-GOT" flat binary, which doesn't work on ARM. In fact, elf2flt on ARM really except to have non-PIC code as input, so we must disable DOPIC in the uClibc configuration. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> --- package/uclibc/uclibc.mk | 9 +++++++++ 1 file changed, 9 insertions(+)