Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1518642 > unrolled thread

[PATCH] um: Fix compile failure due to current_text_address() definition

Started byKeno Fischer <keno@juliacomputing.com>
First post2016-11-10 03:00 +0100
Last post2016-11-16 15:40 +0100
Articles 11 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] um: Fix compile failure due to current_text_address()  definition Keno Fischer <keno@juliacomputing.com> - 2016-11-10 03:00 +0100
    Re: [PATCH] um: Fix compile failure due to current_text_address()  definition Richard Weinberger <richard@nod.at> - 2016-11-10 09:10 +0100
      Re: [PATCH] um: Fix compile failure due to current_text_address() definition Keno Fischer <keno@juliacomputing.com> - 2016-11-10 21:20 +0100
        Re: [PATCH] um: Fix compile failure due to current_text_address()  definition Richard Weinberger <richard@nod.at> - 2016-11-10 21:20 +0100
          Re: [PATCH] um: Fix compile failure due to current_text_address() definition Keno Fischer <keno@juliacomputing.com> - 2016-11-10 21:20 +0100
            Re: [PATCH] um: Fix compile failure due to current_text_address()  definition Richard Weinberger <richard@nod.at> - 2016-11-10 21:20 +0100
              Re: [PATCH] um: Fix compile failure due to current_text_address() definition Keno Fischer <keno@juliacomputing.com> - 2016-11-10 21:50 +0100
    Re: [PATCH] um: Fix compile failure due to current_text_address()  definition Richard Weinberger <richard@nod.at> - 2016-11-11 11:40 +0100
      Re: [PATCH] um: Fix compile failure due to current_text_address()  definition Richard Weinberger <richard@nod.at> - 2016-11-11 23:10 +0100
        Re: [PATCH] um: Fix compile failure due to current_text_address() definition Keno Fischer <keno@juliacomputing.com> - 2016-11-16 04:50 +0100
          Re: [PATCH] um: Fix compile failure due to current_text_address()  definition Richard Weinberger <richard@nod.at> - 2016-11-16 15:40 +0100

#1518642 — [PATCH] um: Fix compile failure due to current_text_address() definition

FromKeno Fischer <keno@juliacomputing.com>
Date2016-11-10 03:00 +0100
Subject[PATCH] um: Fix compile failure due to current_text_address() definition
Message-ID<sBMOJ-7gR-7@gated-at.bofh.it>
Fixes the following link error:
```
/usr/bin/ld: net/built-in.o: relocation R_X86_64_32S against `.text'
can not be used when making a shared object; recompile with -fPIC
```

This is the same definition used on some other architectures.

Signed-off-by: Keno Fischer <keno@juliacomputing.com>
---
I am not sure this is the correct patch in the context of uml. I believe this
should give the runtime ip, which may be different between runs. It may be
better to use the offset in .text (e.g. by using `pc-__text_start`), which
should be consistent.

 arch/x86/um/asm/processor_64.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/um/asm/processor_64.h b/arch/x86/um/asm/processor_64.h
index c3be852..6ca3304 100644
--- a/arch/x86/um/asm/processor_64.h
+++ b/arch/x86/um/asm/processor_64.h
@@ -32,7 +32,7 @@ static inline void arch_copy_thread(struct arch_thread *from,
 }
 
 #define current_text_addr() \
-	({ void *pc; __asm__("movq $1f,%0\n1:":"=g" (pc)); pc; })
+	({ __label__ _l; _l: &&_l; })
 
 #define current_sp() ({ void *sp; __asm__("movq %%rsp, %0" : "=r" (sp) : ); sp; })
 #define current_bp() ({ unsigned long bp; __asm__("movq %%rbp, %0" : "=r" (bp) : ); bp; })
-- 
2.9.3

[toc] | [next] | [standalone]


#1518730

FromRichard Weinberger <richard@nod.at>
Date2016-11-10 09:10 +0100
Message-ID<sBSAN-2Uu-5@gated-at.bofh.it>
In reply to#1518642
Keno,

On 10.11.2016 02:53, Keno Fischer wrote:
> Fixes the following link error:
> ```
> /usr/bin/ld: net/built-in.o: relocation R_X86_64_32S against `.text'
> can not be used when making a shared object; recompile with -fPIC
> ```
> 
> This is the same definition used on some other architectures.
> 
> Signed-off-by: Keno Fischer <keno@juliacomputing.com>
> ---
> I am not sure this is the correct patch in the context of uml. I believe this
> should give the runtime ip, which may be different between runs. It may be
> better to use the offset in .text (e.g. by using `pc-__text_start`), which
> should be consistent.

The problem is ready being solved in a generic way:
http://marc.info/?l=linux-kernel&m=147828481602561&w=2

Can you please give this patch a try?

Thanks,
//richard

[toc] | [prev] | [next] | [standalone]


#1519336 — Re: [PATCH] um: Fix compile failure due to current_text_address() definition

FromKeno Fischer <keno@juliacomputing.com>
Date2016-11-10 21:20 +0100
SubjectRe: [PATCH] um: Fix compile failure due to current_text_address() definition
Message-ID<sC3Zf-2IW-17@gated-at.bofh.it>
In reply to#1518730
> The problem is ready being solved in a generic way:
> http://marc.info/?l=linux-kernel&m=147828481602561&w=2
>
> Can you please give this patch a try?

No dice. After backing out my patch and applying that one I get:

/usr/bin/ld: error: net/built-in.o: requires unsupported dynamic reloc
11; recompile with -fPIC

[toc] | [prev] | [next] | [standalone]


#1519338

FromRichard Weinberger <richard@nod.at>
Date2016-11-10 21:20 +0100
Message-ID<sC3Zf-2IW-19@gated-at.bofh.it>
In reply to#1519336
Keno,

On 10.11.2016 21:10, Keno Fischer wrote:
>> The problem is ready being solved in a generic way:
>> http://marc.info/?l=linux-kernel&m=147828481602561&w=2
>>
>> Can you please give this patch a try?
> 
> No dice. After backing out my patch and applying that one I get:
> 
> /usr/bin/ld: error: net/built-in.o: requires unsupported dynamic reloc
> 11; recompile with -fPIC

But you applied the whole series, right?

Thanks,
//richard

[toc] | [prev] | [next] | [standalone]


#1519339 — Re: [PATCH] um: Fix compile failure due to current_text_address() definition

FromKeno Fischer <keno@juliacomputing.com>
Date2016-11-10 21:20 +0100
SubjectRe: [PATCH] um: Fix compile failure due to current_text_address() definition
Message-ID<sC3Zf-2IW-21@gated-at.bofh.it>
In reply to#1519338
Yes

On Thu, Nov 10, 2016 at 3:14 PM, Richard Weinberger <richard@nod.at> wrote:
> Keno,
>
> On 10.11.2016 21:10, Keno Fischer wrote:
>>> The problem is ready being solved in a generic way:
>>> http://marc.info/?l=linux-kernel&m=147828481602561&w=2
>>>
>>> Can you please give this patch a try?
>>
>> No dice. After backing out my patch and applying that one I get:
>>
>> /usr/bin/ld: error: net/built-in.o: requires unsupported dynamic reloc
>> 11; recompile with -fPIC
>
> But you applied the whole series, right?
>
> Thanks,
> //richard

[toc] | [prev] | [next] | [standalone]


#1519340

FromRichard Weinberger <richard@nod.at>
Date2016-11-10 21:20 +0100
Message-ID<sC3Zf-2IW-25@gated-at.bofh.it>
In reply to#1519339
Keno,

On 10.11.2016 21:14, Keno Fischer wrote:
> Yes

Can you please reply to Sebastian's patch series and explain him how you trigger
that error?
I don't have a gcc broken by Debian on my machine right now.

> On Thu, Nov 10, 2016 at 3:14 PM, Richard Weinberger <richard@nod.at> wrote:
>> Keno,
>>
>> On 10.11.2016 21:10, Keno Fischer wrote:
>>>> The problem is ready being solved in a generic way:
>>>> http://marc.info/?l=linux-kernel&m=147828481602561&w=2
>>>>
>>>> Can you please give this patch a try?
>>>
>>> No dice. After backing out my patch and applying that one I get:
>>>
>>> /usr/bin/ld: error: net/built-in.o: requires unsupported dynamic reloc
>>> 11; recompile with -fPIC
>>
>> But you applied the whole series, right?

Thanks,
//richard

[toc] | [prev] | [next] | [standalone]


#1519356 — Re: [PATCH] um: Fix compile failure due to current_text_address() definition

FromKeno Fischer <keno@juliacomputing.com>
Date2016-11-10 21:50 +0100
SubjectRe: [PATCH] um: Fix compile failure due to current_text_address() definition
Message-ID<sC4sh-2Vb-9@gated-at.bofh.it>
In reply to#1519340
On Thu, Nov 10, 2016 at 3:19 PM, Richard Weinberger <richard@nod.at> wrote:
> Can you please reply to Sebastian's patch series and explain him how you trigger
> that error?
> I don't have a gcc broken by Debian on my machine right now.

I'm not sure how to reply to his patch series directly since I'm not
subscribed to lkml
(I imagine I can set headers manually, such that things get
appropriately threaded,
but for now let me just reply here). I don't think there's much to it.
It seems like any
use of `current_text_addr()` in `ARCH=um` build will cause this
problem, there's just
not very many such uses in the code base. I believe this particular
problem should
be reproducible as long as CONFIG_INET is set for an `ARCH=um` build.

[toc] | [prev] | [next] | [standalone]


#1519678

FromRichard Weinberger <richard@nod.at>
Date2016-11-11 11:40 +0100
Message-ID<sChpw-392-27@gated-at.bofh.it>
In reply to#1518642
Keno,

On 10.11.2016 02:53, Keno Fischer wrote:
> Fixes the following link error:
> ```
> /usr/bin/ld: net/built-in.o: relocation R_X86_64_32S against `.text'
> can not be used when making a shared object; recompile with -fPIC
> ```

How and where do you trigger this?
I had a chat with Sebastian and we are not 100% sure what is going on.
On my freshly installed Debian sid with gcc version 6.2.0 20161109 (Debian 6.2.0-13)
UML builds fine except when I set CONFIG_STATIC_LINK=y

But then I'm facing a slightly different error:
  CC      init/version.o
  LD      init/built-in.o
/usr/bin/ld: init/built-in.o: relocation R_X86_64_PLTOFF64 against STT_GNU_IFUNC symbol `memmove' isn't supported
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

Your patch also does not cure this. I'll investigate later into that.

> This is the same definition used on some other architectures.
> 
> Signed-off-by: Keno Fischer <keno@juliacomputing.com>
> ---
> I am not sure this is the correct patch in the context of uml. I believe this
> should give the runtime ip, which may be different between runs. It may be
> better to use the offset in .text (e.g. by using `pc-__text_start`), which
> should be consistent.
> 
>  arch/x86/um/asm/processor_64.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/um/asm/processor_64.h b/arch/x86/um/asm/processor_64.h
> index c3be852..6ca3304 100644
> --- a/arch/x86/um/asm/processor_64.h
> +++ b/arch/x86/um/asm/processor_64.h
> @@ -32,7 +32,7 @@ static inline void arch_copy_thread(struct arch_thread *from,
>  }
>  
>  #define current_text_addr() \
> -	({ void *pc; __asm__("movq $1f,%0\n1:":"=g" (pc)); pc; })
> +	({ __label__ _l; _l: &&_l; })
>  
>  #define current_sp() ({ void *sp; __asm__("movq %%rsp, %0" : "=r" (sp) : ); sp; })
>  #define current_bp() ({ unsigned long bp; __asm__("movq %%rbp, %0" : "=r" (bp) : ); bp; })

Thanks,
//richard

[toc] | [prev] | [next] | [standalone]


#1520056

FromRichard Weinberger <richard@nod.at>
Date2016-11-11 23:10 +0100
Message-ID<sCsbf-1Q9-9@gated-at.bofh.it>
In reply to#1519678
On 11.11.2016 22:03, Keno Fischer wrote:
> Did you have CONFIG_INET set? I'm attaching my full .config. This is
> on vanilla Ubuntu 16.10.

Yes, CONFIG_INET is set. Let my try on Ubuntu. ;-\

> I did see the same error when building with `CONFIG_STATIC_LINK=y`.
> Note that I also, separately, ran into a linker problem, though I
> believe it is unrelated to this patch
> (though perhaps is related to the problem you're seeing?):
> https://sourceware.org/bugzilla/show_bug.cgi?id=20800.

This seems to be an UML<->glibc issue.
memmove() is now an ifunc and for whatever reason it does not work with UML.

> I'd also be happy to provide you with ssh access to the machine that
> I'm seeing this on if that
> would be helpful.

Okay, let me try myself first. I think I'm able to install Ubuntu. :)

Thanks,
//richard

[toc] | [prev] | [next] | [standalone]


#1523216 — Re: [PATCH] um: Fix compile failure due to current_text_address() definition

FromKeno Fischer <keno@juliacomputing.com>
Date2016-11-16 04:50 +0100
SubjectRe: [PATCH] um: Fix compile failure due to current_text_address() definition
Message-ID<sDZot-5zy-7@gated-at.bofh.it>
In reply to#1520056
Just as an FYI, the linker bug has been fixed in binutils.

On Fri, Nov 11, 2016 at 5:07 PM, Richard Weinberger <richard@nod.at> wrote:
> On 11.11.2016 22:03, Keno Fischer wrote:
>> Did you have CONFIG_INET set? I'm attaching my full .config. This is
>> on vanilla Ubuntu 16.10.
>
> Yes, CONFIG_INET is set. Let my try on Ubuntu. ;-\
>
>> I did see the same error when building with `CONFIG_STATIC_LINK=y`.
>> Note that I also, separately, ran into a linker problem, though I
>> believe it is unrelated to this patch
>> (though perhaps is related to the problem you're seeing?):
>> https://sourceware.org/bugzilla/show_bug.cgi?id=20800.
>
> This seems to be an UML<->glibc issue.
> memmove() is now an ifunc and for whatever reason it does not work with UML.
>
>> I'd also be happy to provide you with ssh access to the machine that
>> I'm seeing this on if that
>> would be helpful.
>
> Okay, let me try myself first. I think I'm able to install Ubuntu. :)
>
> Thanks,
> //richard

[toc] | [prev] | [next] | [standalone]


#1523535

FromRichard Weinberger <richard@nod.at>
Date2016-11-16 15:40 +0100
Message-ID<sE9xw-48I-23@gated-at.bofh.it>
In reply to#1523216
Keno,

On 16.11.2016 04:45, Keno Fischer wrote:
> Just as an FYI, the linker bug has been fixed in binutils.

Interesting. Is the same bug also the root cause why a static build
of UML does not work?

Thanks,
//richard

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web