Differences between revisions 36 and 37
Revision 36 as of 2017-12-11 18:18:17
Size: 5679
Editor: azanella
Comment:
Revision 37 as of 2017-12-16 01:27:11
Size: 8007
Editor: H.J. Lu
Comment:
Deletions are marked like this. Additions are marked like this.
Line 78: Line 78:
== Static PIE ===

Static position independent executable (static PIE) support has been added to glibc 2.27, which can be enabled by
configuring glibc with --enable-static-pie. This feature is currently supported on i386, x86_64 and x32. Static
PIE requires:

1. Target must support accessing of local functions without dynamic
relocations, which is needed in start.S to call __libc_start_main with
function addresses of {{{__libc_csu_init}}}, {{{__libc_csu_fini}}} and {{{main}}}. All
functions in static PIE are local functions. If PIE {{{start.S}}} can't reach
{{{main}}} defined in a shared object, the code sequence:

{{{
 pass address of local_main to __libc_start_main
 ...

local_main:
 tail call to main via PLT
}}}

can be used.

2. {{{start.S}}} is updated to check PIC instead SHARED for PIC code path and
avoid dynamic relocation, when PIC is defined and SHARED isn't defined,
to support static PIE.

3. All assembly codes are updated check PIC instead SHARED for PIC code
path to avoid dynamic relocations in read-only sections.

4. All assembly codes are updated check SHARED instead PIC for static
symbol name.

5. {{{elf_machine_load_address}}} in {{{dl-machine.h}}} are updated to support static
PIE.

6. {{{__brk}}} works without TLS nor dynamic relocations in read-only section
so that it can be used by {{{__libc_setup_tls}}} to initializes TLS in static
PIE.

Linker requirements to build glibc with --enable-static-pie:

1. Linker supports --no-dynamic-linker to remove PT_INTERP segment from
static PIE.

2. Linker can create working static PIE. The x86-64 linker needs the
fix for

https://sourceware.org/bugzilla/show_bug.cgi?id=21782

The i386 linker needs to be able to convert

{{{
movl main@GOT(%ebx), %eax
}}}

to

{{{
leal main@GOTOFF(%ebx), %eax
}}}

if {{{main}}} is defined locally.

Binutils 2.29 or above are OK for i686 and x86-64. But linker status for
other targets need to be verified.

3. Linker should resolve undefined weak symbols to 0 in static PIE:

https://sourceware.org/bugzilla/show_bug.cgi?id=22269

4. Many ELF backend linkers incorrectly check {{{bfd_link_pic}}} for TLS
relocations, which should check {{{bfd_link_executable}}} instead:

https://sourceware.org/bugzilla/show_bug.cgi?id=22263

Port Status

This page lists issues for which some ports need updating to take account of global changes to glibc or features initially implemented only for some ports. Each issue should list the ports for which it's relevant. When making a change needing port updates, please add details to this page. When fixing an issue for a port, please remove the port from the list of those to which the issue applies (and remove the issue from the page if it was the last port affected).

This is in addition to any port-specific issues that may be filed in Bugzilla, or that may show up through testsuite failures (it's generally a good idea to file such issues in Bugzilla, if they appear to indicate port bugs and you aren't immediately fixing them).

Generally, libm-test-ulps should be regenerated from scratch for each architecture for each release, but this is not mentioned on this page.

ABI test baselines

Needed for: Hurd.

ABI test baselines should be checked against binaries of as many past releases as possible rather than presuming no ABI bugs have crept in while the ABI was not being tested.

c++-types.data

Needed for: Hurd.

bits/mman.h using mman-linux.h

Needed for: hppa.

For GNU/Linux, bits/mman.h should use bits/mman-linux.h to define architecture-independent values and only define things itself where architecture-dependent (if needed, make more definitions in bits/mman-linux.h support the values being architecture-specific). For hppa, doing this should fix the missing definitions of MADV_HUGEPAGE, MADV_NOHUGEPAGE, MADV_DONTDUMP, MADV_DODUMP and MADV_HWPOISON. This isn't straightforward though because hppa has custom values for more defines than other arches.

Handle ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA

Needed for: alpha hppa ia64 m68k microblaze mips powerpc s390 sh sparc tile. See candidate MIPS patch (seems to require binutils changes).

Handle ELF_RTYPE_CLASS_EXTERN_PROTECTED_DATA in elf_machine_type_class and define DL_EXTERN_PROTECTED_DATA, or establish a reason why this is not required for the given architecture. Note that the tests elf/tst-protected1a and elf/tst-protected1b may or may not run at all depending on the results of a configure test on linker support, and binutils (and possibly GCC) fixes may be needed for them to pass as well as glibc fixes.

Remove unnecessary soft-fp directory layers

Needed for: aarch64 alpha powerpc sh sparc.

sysdeps subdirectories sysdeps/$arch/soft-fp should be merged into sysdeps/$arch. See message.

Syscall cancellation handling (NOT UPSTREAM)

Needed for: all architectures.

The new cancellation syscall wrapper for GLIBC provides a default implementation (sysdeps/unix/sysv/linux/syscall_cancel.c), however the architecture might require a assembly crafted implementation (for instance if the syscall itself is done through a kernel gate as for i686 or ia64 or if it requires a special gate due ABI constraint like ARM). If the default implementation places the requires syscall_cancel_arch_start and syscall_cancel_arch_end marks in the expected places (before the test of the cancellation flags and after the syscall instruction trap respectively) there is no need write the syscall_cancel wrapper.

1. Write a new syscall implementation at sysdeps/unix/sysv/linux/<arch>/syscall_cancel.S with following semantic:

long int __syscall_cancel_arch (volatile unsigned int *cancelhandling,
  __syscall_arg_t nr, __syscall_arg_t arg1, __syscall_arg_t arg2, 
  __syscall_arg_t arg3, __syscall_arg_t arg4, __syscall_arg_t arg5,
  __syscall_arg_t arg6)
{
  if (*cancelhandling & CANCELED_BITMASK)
    __syscall_do_cancel()

  INTERNAL_SYSCALL_DECL (err);
  result = INTERNAL_SYSCALL_NCS (nr, err, 6, a1, a2, a3, a4, a5, a6);
  if (INTERNAL_SYSCALL_ERROR_P (result, err))
    return -INTERNAL_SYSCALL_ERRNO (result, err);
  return result;
}

* If the architectures requires a cancellation entrypoint for 7 argument syscalls (as for MIPSo32) it will need to define SYSCALL_CANCEL7_ARG7 on sysdep.h.

2. Create a function to get current Program Counter based on third argument from a signal handler configure with SA_SIGINFO on architecture sigcontextinfo.h header.

static inline uintptr_t
ucontext_get_pc (const void *cxt)
{
  // TODO: return current program counter based on uc.  Usually 
  // the CTX points to a ucontext_t, however it is architecture
  // dependent (for instance sparc calls with sigcontext).
}

* If the signal frame signal mask is not directly accessible through the CTX pointer (either because the kernel invokes the handler with a different object than ucontext_t, as SPARC; or due type mismatch between kernel and glibc, as for IA64) the architecture might define UCONTEXT_SIGMASK to get the uc_mask pointer.

== Static PIE ===

Static position independent executable (static PIE) support has been added to glibc 2.27, which can be enabled by configuring glibc with --enable-static-pie. This feature is currently supported on i386, x86_64 and x32. Static PIE requires:

1. Target must support accessing of local functions without dynamic relocations, which is needed in start.S to call libc_start_main with function addresses of __libc_csu_init, __libc_csu_fini and main. All functions in static PIE are local functions. If PIE start.S can't reach main defined in a shared object, the code sequence:

        pass address of local_main to __libc_start_main
        ...

local_main:
        tail call to main via PLT

can be used.

2. start.S is updated to check PIC instead SHARED for PIC code path and avoid dynamic relocation, when PIC is defined and SHARED isn't defined, to support static PIE.

3. All assembly codes are updated check PIC instead SHARED for PIC code path to avoid dynamic relocations in read-only sections.

4. All assembly codes are updated check SHARED instead PIC for static symbol name.

5. elf_machine_load_address in dl-machine.h are updated to support static PIE.

6. __brk works without TLS nor dynamic relocations in read-only section so that it can be used by __libc_setup_tls to initializes TLS in static PIE.

Linker requirements to build glibc with --enable-static-pie:

1. Linker supports --no-dynamic-linker to remove PT_INTERP segment from static PIE.

2. Linker can create working static PIE. The x86-64 linker needs the fix for

https://sourceware.org/bugzilla/show_bug.cgi?id=21782

The i386 linker needs to be able to convert

movl main@GOT(%ebx), %eax

to

leal main@GOTOFF(%ebx), %eax

if main is defined locally.

Binutils 2.29 or above are OK for i686 and x86-64. But linker status for other targets need to be verified.

3. Linker should resolve undefined weak symbols to 0 in static PIE:

https://sourceware.org/bugzilla/show_bug.cgi?id=22269

4. Many ELF backend linkers incorrectly check bfd_link_pic for TLS relocations, which should check bfd_link_executable instead:

https://sourceware.org/bugzilla/show_bug.cgi?id=22263

Issues specific to hppa

The following issues are ones for which only hppa has not been updated.

  • An entry in libc's sysdeps/unix/sysv/linux/configure.in for hppa was removed on 2012-01-07 and a ports update may be needed. That entry may actually have been dead because of the arch_minimum_kernel setting in sysdeps/unix/sysv/linux/hppa/nptl/configure.in - but in that case, there's the question of whether the libc_cv_gcc_unwind_find_fde=yes that was in libc's file for hppa should go in the ports version (if that was a correct description of old libc binaries on hppa).

None: PortStatus (last edited 2017-12-16 01:27:11 by H.J. Lu)