This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] RFC: avoid cancellable I/O primitives in ld.so



On 03/04/2018 22:43, Zack Weinberg wrote:
> Neither the <dlfcn.h> entry points, nor lazy symbol resolution, nor
> initial shared library load-up, are cancellation points, so ld.so
> should exclusively use I/O primitives that are not cancellable; in
> addition to streamlining low-level operations, this means we do not
> require a copy of nptl/unwind.c in ld.so.
> 
> The bulk of the change is splitting up the files that define the
> _nocancel I/O functions, so they don't also define the variants that
> *are* cancellation points; after which, the existing logic for picking
> out the bits of libc that need to be recompiled as part of ld.so Just
> Works.  I did this for all of the _nocancel functions, not just the
> ones used by ld.so, for consistency.
> 

There is no need to call *_cancel primitives in loader, rtld-* objects
will built with both LIBC_CANCEL_ASYNC and LIBC_CANCEL_RESET being dummy
values:

nptl/pthreadP.h:
334 # define LIBC_CANCEL_ASYNC()    0 /* Just a dummy value.  */
335 # define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it.  */
336 # define LIBC_CANCEL_HANDLED()  /* Nothing.  */

For instance, 'io/rtld-close.os' is really what you expect for a
non-cancellable syscall:

$ objdump -d ./io/rtld-close.os
[...]
0000000000000000 <__close>:
   0:   b8 03 00 00 00          mov    $0x3,%eax
   5:   0f 05                   syscall 
   7:   48 3d 00 f0 ff ff       cmp    $0xfffffffffffff000,%rax
   d:   77 09                   ja     18 <__close+0x18>
   f:   f3 c3                   repz retq 
  11:   0f 1f 80 00 00 00 00    nopl   0x0(%rax)
  18:   f7 d8                   neg    %eax
  1a:   89 05 00 00 00 00       mov    %eax,0x0(%rip)        # 20 <__close+0x20>
  20:   b8 ff ff ff ff          mov    $0xffffffff,%eax
  25:   c3                      retq   

So why do you need to explicit call *_cancel symbols?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]