[llvm-dev] LTO, ifuncs, and lld

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[llvm-dev] LTO, ifuncs, and lld

Alberto Barbaro via llvm-dev
Hey LLVM folks,

I've run into an interesting assertion. In one of HardenedBSD's
feature branches, we're working on integration llvm's Cross-DSO CFI
implementation. Using Cross-DSO CFI requires building libs with LTO,
which causes clang to emit LLVM IR intermediate object files rather
than ELF intermediate object files.

I've found that with lld, attempting to link LLVM IR intermediate
object files hits an assert in lld. I've created a reproduction test
case in this tiny little repo: https://github.com/lattera/ifunc_repro

The assertion I hit is detailed in the commit message of the initial
commit:
https://github.com/lattera/ifunc_repro/commit/0be98f9e81a1c91e80b135da6bb8d073d7a0c6f7

HardenedBSD's Cross-DSO CFI feature branch uses clang/llvm/lld 7.0.1.
I'm more than happy to test out patches to help address this issue.

Please let me know if you have any questions, comments, or concerns.

Thanks,

--
Shawn Webb
Cofounder and Security Engineer
HardenedBSD

Tor-ified Signal:    +1 443-546-8752
Tor+XMPP+OTR:        [hidden email]
GPG Key ID:          0x6A84658F52456EEE
GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] LTO, ifuncs, and lld

Alberto Barbaro via llvm-dev
Hi Shawn,

Can you please create a reproducer tarball (using ld.lld --reproduce) so that we don't need to install HardenedBSD in order to reproduce?

Peter

On Wed, Nov 28, 2018 at 5:16 PM Shawn Webb via llvm-dev <[hidden email]> wrote:
Hey LLVM folks,

I've run into an interesting assertion. In one of HardenedBSD's
feature branches, we're working on integration llvm's Cross-DSO CFI
implementation. Using Cross-DSO CFI requires building libs with LTO,
which causes clang to emit LLVM IR intermediate object files rather
than ELF intermediate object files.

I've found that with lld, attempting to link LLVM IR intermediate
object files hits an assert in lld. I've created a reproduction test
case in this tiny little repo: https://github.com/lattera/ifunc_repro

The assertion I hit is detailed in the commit message of the initial
commit:
https://github.com/lattera/ifunc_repro/commit/0be98f9e81a1c91e80b135da6bb8d073d7a0c6f7

HardenedBSD's Cross-DSO CFI feature branch uses clang/llvm/lld 7.0.1.
I'm more than happy to test out patches to help address this issue.

Please let me know if you have any questions, comments, or concerns.

Thanks,

--
Shawn Webb
Cofounder and Security Engineer
HardenedBSD

Tor-ified Signal:    +1 443-546-8752
Tor+XMPP+OTR:        [hidden email]
GPG Key ID:          0x6A84658F52456EEE
GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


--
-- 
Peter

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] LTO, ifuncs, and lld

Alberto Barbaro via llvm-dev
Hey Peter,

Here you go!

https://hardenedbsd.org/~shawn/2018-11-28_reproduce-01.tar

Thanks,

--
Shawn Webb
Cofounder and Security Engineer
HardenedBSD

Tor-ified Signal:    +1 443-546-8752
Tor+XMPP+OTR:        [hidden email]
GPG Key ID:          0x6A84658F52456EEE
GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE

On Wed, Nov 28, 2018 at 05:30:57PM -0800, Peter Collingbourne wrote:

> Hi Shawn,
>
> Can you please create a reproducer tarball (using ld.lld --reproduce) so
> that we don't need to install HardenedBSD in order to reproduce?
>
> Peter
>
> On Wed, Nov 28, 2018 at 5:16 PM Shawn Webb via llvm-dev <
> [hidden email]> wrote:
>
> > Hey LLVM folks,
> >
> > I've run into an interesting assertion. In one of HardenedBSD's
> > feature branches, we're working on integration llvm's Cross-DSO CFI
> > implementation. Using Cross-DSO CFI requires building libs with LTO,
> > which causes clang to emit LLVM IR intermediate object files rather
> > than ELF intermediate object files.
> >
> > I've found that with lld, attempting to link LLVM IR intermediate
> > object files hits an assert in lld. I've created a reproduction test
> > case in this tiny little repo: https://github.com/lattera/ifunc_repro
> >
> > The assertion I hit is detailed in the commit message of the initial
> > commit:
> >
> > https://github.com/lattera/ifunc_repro/commit/0be98f9e81a1c91e80b135da6bb8d073d7a0c6f7
> >
> > HardenedBSD's Cross-DSO CFI feature branch uses clang/llvm/lld 7.0.1.
> > I'm more than happy to test out patches to help address this issue.
> >
> > Please let me know if you have any questions, comments, or concerns.
> >
> > Thanks,
> >
> > --
> > Shawn Webb
> > Cofounder and Security Engineer
> > HardenedBSD
> >
> > Tor-ified Signal:    +1 443-546-8752
> > Tor+XMPP+OTR:        [hidden email]
> > GPG Key ID:          0x6A84658F52456EEE
> > GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE
> > _______________________________________________
> > LLVM Developers mailing list
> > [hidden email]
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> >
>
>
> --
> --
> Peter

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] LTO, ifuncs, and lld

Alberto Barbaro via llvm-dev
https://reviews.llvm.org/D55046 fixes your reproducer here. Let me know if that works for you.

Note that I had to rebuild one of your bitcode files to be a regular object file, this is because LTO doesn't want the .eh_frame terminator to live in a bitcode file.

$ mv ./usr/lib/crtendS.o ./usr/lib/crtendS.o.bak
$ ~/l4/ra/bin/llc -o ./usr/lib/crtendS.o ./usr/lib/crtendS.o.bak -filetype=obj -relocation-model=pic

Peter

On Wed, Nov 28, 2018 at 5:35 PM Shawn Webb <[hidden email]> wrote:
Hey Peter,

Here you go!

https://hardenedbsd.org/~shawn/2018-11-28_reproduce-01.tar

Thanks,

--
Shawn Webb
Cofounder and Security Engineer
HardenedBSD

Tor-ified Signal:    +1 443-546-8752
Tor+XMPP+OTR:        [hidden email]
GPG Key ID:          0x6A84658F52456EEE
GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE

On Wed, Nov 28, 2018 at 05:30:57PM -0800, Peter Collingbourne wrote:
> Hi Shawn,
>
> Can you please create a reproducer tarball (using ld.lld --reproduce) so
> that we don't need to install HardenedBSD in order to reproduce?
>
> Peter
>
> On Wed, Nov 28, 2018 at 5:16 PM Shawn Webb via llvm-dev <
> [hidden email]> wrote:
>
> > Hey LLVM folks,
> >
> > I've run into an interesting assertion. In one of HardenedBSD's
> > feature branches, we're working on integration llvm's Cross-DSO CFI
> > implementation. Using Cross-DSO CFI requires building libs with LTO,
> > which causes clang to emit LLVM IR intermediate object files rather
> > than ELF intermediate object files.
> >
> > I've found that with lld, attempting to link LLVM IR intermediate
> > object files hits an assert in lld. I've created a reproduction test
> > case in this tiny little repo: https://github.com/lattera/ifunc_repro
> >
> > The assertion I hit is detailed in the commit message of the initial
> > commit:
> >
> > https://github.com/lattera/ifunc_repro/commit/0be98f9e81a1c91e80b135da6bb8d073d7a0c6f7
> >
> > HardenedBSD's Cross-DSO CFI feature branch uses clang/llvm/lld 7.0.1.
> > I'm more than happy to test out patches to help address this issue.
> >
> > Please let me know if you have any questions, comments, or concerns.
> >
> > Thanks,
> >
> > --
> > Shawn Webb
> > Cofounder and Security Engineer
> > HardenedBSD
> >
> > Tor-ified Signal:    +1 443-546-8752
> > Tor+XMPP+OTR:        [hidden email]
> > GPG Key ID:          0x6A84658F52456EEE
> > GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE
> > _______________________________________________
> > LLVM Developers mailing list
> > [hidden email]
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> >
>
>
> --
> --
> Peter


--
-- 
Peter

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|

Re: [llvm-dev] LTO, ifuncs, and lld

Alberto Barbaro via llvm-dev
Thanks for providing the patch! I got around to testing it this
morning and it appears it fixes compilation, but produces a
non-working system.

I know that's kinda vague and I'll have more details soon, including
sample binaries. I at least wanted to give a status update so you
didn't think you were being ignored.

Thanks,

--
Shawn Webb
Cofounder and Security Engineer
HardenedBSD

Tor-ified Signal:    +1 443-546-8752
Tor+XMPP+OTR:        [hidden email]
GPG Key ID:          0x6A84658F52456EEE
GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE

On Wed, Nov 28, 2018 at 09:16:24PM -0800, Peter Collingbourne wrote:

> https://reviews.llvm.org/D55046 fixes your reproducer here. Let me know if
> that works for you.
>
> Note that I had to rebuild one of your bitcode files to be a regular object
> file, this is because LTO doesn't want the .eh_frame terminator to live in
> a bitcode file.
>
> $ mv ./usr/lib/crtendS.o ./usr/lib/crtendS.o.bak
> $ ~/l4/ra/bin/llc -o ./usr/lib/crtendS.o ./usr/lib/crtendS.o.bak
> -filetype=obj -relocation-model=pic
>
> Peter
>
> On Wed, Nov 28, 2018 at 5:35 PM Shawn Webb <[hidden email]>
> wrote:
>
> > Hey Peter,
> >
> > Here you go!
> >
> > https://hardenedbsd.org/~shawn/2018-11-28_reproduce-01.tar
> >
> > Thanks,
> >
> > --
> > Shawn Webb
> > Cofounder and Security Engineer
> > HardenedBSD
> >
> > Tor-ified Signal:    +1 443-546-8752
> > Tor+XMPP+OTR:        [hidden email]
> > GPG Key ID:          0x6A84658F52456EEE
> > GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE
> >
> > On Wed, Nov 28, 2018 at 05:30:57PM -0800, Peter Collingbourne wrote:
> > > Hi Shawn,
> > >
> > > Can you please create a reproducer tarball (using ld.lld --reproduce) so
> > > that we don't need to install HardenedBSD in order to reproduce?
> > >
> > > Peter
> > >
> > > On Wed, Nov 28, 2018 at 5:16 PM Shawn Webb via llvm-dev <
> > > [hidden email]> wrote:
> > >
> > > > Hey LLVM folks,
> > > >
> > > > I've run into an interesting assertion. In one of HardenedBSD's
> > > > feature branches, we're working on integration llvm's Cross-DSO CFI
> > > > implementation. Using Cross-DSO CFI requires building libs with LTO,
> > > > which causes clang to emit LLVM IR intermediate object files rather
> > > > than ELF intermediate object files.
> > > >
> > > > I've found that with lld, attempting to link LLVM IR intermediate
> > > > object files hits an assert in lld. I've created a reproduction test
> > > > case in this tiny little repo: https://github.com/lattera/ifunc_repro
> > > >
> > > > The assertion I hit is detailed in the commit message of the initial
> > > > commit:
> > > >
> > > >
> > https://github.com/lattera/ifunc_repro/commit/0be98f9e81a1c91e80b135da6bb8d073d7a0c6f7
> > > >
> > > > HardenedBSD's Cross-DSO CFI feature branch uses clang/llvm/lld 7.0.1.
> > > > I'm more than happy to test out patches to help address this issue.
> > > >
> > > > Please let me know if you have any questions, comments, or concerns.
> > > >
> > > > Thanks,
> > > >
> > > > --
> > > > Shawn Webb
> > > > Cofounder and Security Engineer
> > > > HardenedBSD
> > > >
> > > > Tor-ified Signal:    +1 443-546-8752
> > > > Tor+XMPP+OTR:        [hidden email]
> > > > GPG Key ID:          0x6A84658F52456EEE
> > > > GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89  3D9E 6A84 658F 5245 6EEE
> > > > _______________________________________________
> > > > LLVM Developers mailing list
> > > > [hidden email]
> > > > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> > > >
> > >
> > >
> > > --
> > > --
> > > Peter
> >
>
>
> --
> --
> Peter

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

signature.asc (849 bytes) Download Attachment