diff options
author | Christophe Lyon <christophe.lyon@st.com> | 2018-07-04 17:55:20 +0200 |
---|---|---|
committer | Waldemar Brodkorb <wbrodkorb@conet.de> | 2018-08-10 16:01:58 +0200 |
commit | c86f875f07f2e2ef54ce3741914a5cc74f7ddd3c (patch) | |
tree | 365e80b70dbda2f4412c34493ea69e3d2298df46 /ldso | |
parent | 75bce1a7320f94c36854fc958fa93937ed92bf83 (diff) |
Fix bug in _dl_pread when using pread64 syscall
In ARM_EABI mode, the pread64 syscall parameters are aligned on
64-bits. This syscall is used in rtld when processing FDPIC
relocations.
* ldso/include/dl-syscall.h (__syscall_pread): Fix definition.
(__dl_pread): Fix syscall invocation.
* ldso/ldso/fdpic/dl-sysdep.h (__DL_PREAD): Handle __NR_pread64.
Signed-off-by: Mickaël Guêné <mickael.guene@st.com>
Signed-off-by: Christophe Lyon <christophe.lyon@st.com>
Diffstat (limited to 'ldso')
-rw-r--r-- | ldso/include/dl-syscall.h | 13 | ||||
-rw-r--r-- | ldso/ldso/fdpic/dl-sysdep.h | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/ldso/include/dl-syscall.h b/ldso/include/dl-syscall.h index 5ba8c8780..9d80c6a26 100644 --- a/ldso/include/dl-syscall.h +++ b/ldso/include/dl-syscall.h @@ -159,14 +159,25 @@ static __always_inline _syscall4(int, _dl_readlink, int, id, const char *, path, #ifdef __NR_pread64 #define __NR___syscall_pread __NR_pread64 +#ifdef __UCLIBC_SYSCALL_ALIGN_64BIT__ +static __always_inline _syscall6(ssize_t, __syscall_pread, int, fd, void *, buf, size_t, dummy, + size_t, count, off_t, offset_hi, off_t, offset_lo) + +static __always_inline ssize_t +_dl_pread(int fd, void *buf, size_t count, off_t offset) +{ + return __syscall_pread(fd, buf, count, 0, __LONG_LONG_PAIR((offset >> 32), (offset & 0xffffffff))); +} +#else static __always_inline _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf, size_t, count, off_t, offset_hi, off_t, offset_lo) static __always_inline ssize_t _dl_pread(int fd, void *buf, size_t count, off_t offset) { - return __syscall_pread(fd, buf, count, offset, offset >> 31); + return __syscall_pread(fd, buf, count, __LONG_LONG_PAIR(offset >> 31, offset)); } +#endif #elif defined __NR_pread #define __NR___syscall_pread __NR_pread static __always_inline _syscall5(ssize_t, __syscall_pread, int, fd, void *, buf, diff --git a/ldso/ldso/fdpic/dl-sysdep.h b/ldso/ldso/fdpic/dl-sysdep.h index 546811ad0..6ab303b37 100644 --- a/ldso/ldso/fdpic/dl-sysdep.h +++ b/ldso/ldso/fdpic/dl-sysdep.h @@ -96,7 +96,7 @@ struct funcdesc_ht; elfinterp.c. */ #define DL_SKIP_BOOTSTRAP_RELOC(SYMTAB, INDEX, STRTAB) 0 -#ifdef __NR_pread +#if defined(__NR_pread) || defined(__NR_pread64) #define _DL_PREAD(FD, BUF, SIZE, OFFSET) \ (_dl_pread((FD), (BUF), (SIZE), (OFFSET))) #endif |