[16/17] x86_64: Remove _dl_skip_args usage
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
Commit Message
Since ad43cac44a the generic code already shuffles the argv/envp/auxv
on the stack to remove the ld.so own arguments and thus _dl_skip_args
is always 0. So there is no need to adjust the argc or argv.
Checked on x86_64-linux-gnu and i686-linux-gnu.
---
sysdeps/x86_64/dl-machine.h | 13 ++-----------
sysdeps/x86_64/x32/dl-machine.h | 12 +-----------
2 files changed, 3 insertions(+), 22 deletions(-)
Comments
On Thu, May 26, 2022 at 10:02 AM Adhemerval Zanella via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> Since ad43cac44a the generic code already shuffles the argv/envp/auxv
> on the stack to remove the ld.so own arguments and thus _dl_skip_args
> is always 0. So there is no need to adjust the argc or argv.
>
> Checked on x86_64-linux-gnu and i686-linux-gnu.
> ---
> sysdeps/x86_64/dl-machine.h | 13 ++-----------
> sysdeps/x86_64/x32/dl-machine.h | 12 +-----------
> 2 files changed, 3 insertions(+), 22 deletions(-)
>
> diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
> index c70af7ab1e..e33ca2cc1a 100644
> --- a/sysdeps/x86_64/dl-machine.h
> +++ b/sysdeps/x86_64/dl-machine.h
> @@ -140,17 +140,8 @@ _start:\n\
> _dl_start_user:\n\
> # Save the user entry point address in %r12.\n\
> movq %rax, %r12\n\
> - # See if we were run as a command with the executable file\n\
> - # name as an extra leading argument.\n\
> - movl _dl_skip_args(%rip), %eax\n\
> - # Pop the original argument count.\n\
> - popq %rdx\n\
> - # Adjust the stack pointer to skip _dl_skip_args words.\n\
> - leaq (%rsp,%rax,8), %rsp\n\
> - # Subtract _dl_skip_args from argc.\n\
> - subl %eax, %edx\n\
> - # Push argc back on the stack.\n\
> - pushq %rdx\n\
> + # Read the original argument count.\n\
> + movq (%rsp), %rdx\n\
> # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\
> # argc -> rsi\n\
> movq %rdx, %rsi\n\
> diff --git a/sysdeps/x86_64/x32/dl-machine.h b/sysdeps/x86_64/x32/dl-machine.h
> index 331374069e..681016c8d8 100644
> --- a/sysdeps/x86_64/x32/dl-machine.h
> +++ b/sysdeps/x86_64/x32/dl-machine.h
> @@ -45,18 +45,8 @@ _start:\n\
> _dl_start_user:\n\
> # Save the user entry point address in %r12.\n\
> movl %eax, %r12d\n\
> - # See if we were run as a command with the executable file\n\
> - # name as an extra leading argument.\n\
> - movl _dl_skip_args(%rip), %eax\n\
> - # Pop the original argument count.\n\
> + # Read the original argument count.\n\
> movl (%rsp), %edx\n\
> - # Adjust the stack pointer to skip _dl_skip_args words.\n\
> - lea 4(%rsp,%rax,4), %esp\n\
> - # Subtract _dl_skip_args from argc.\n\
> - subl %eax, %edx\n\
> - # Push argc back on the stack.\n\
> - subl $4, %esp\n\
> - movl %edx, (%rsp)\n\
> # Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\
> # argc -> rsi\n\
> movl %edx, %esi\n\
> --
> 2.34.1
>
LGTM.
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Thanks.
@@ -140,17 +140,8 @@ _start:\n\
_dl_start_user:\n\
# Save the user entry point address in %r12.\n\
movq %rax, %r12\n\
- # See if we were run as a command with the executable file\n\
- # name as an extra leading argument.\n\
- movl _dl_skip_args(%rip), %eax\n\
- # Pop the original argument count.\n\
- popq %rdx\n\
- # Adjust the stack pointer to skip _dl_skip_args words.\n\
- leaq (%rsp,%rax,8), %rsp\n\
- # Subtract _dl_skip_args from argc.\n\
- subl %eax, %edx\n\
- # Push argc back on the stack.\n\
- pushq %rdx\n\
+ # Read the original argument count.\n\
+ movq (%rsp), %rdx\n\
# Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\
# argc -> rsi\n\
movq %rdx, %rsi\n\
@@ -45,18 +45,8 @@ _start:\n\
_dl_start_user:\n\
# Save the user entry point address in %r12.\n\
movl %eax, %r12d\n\
- # See if we were run as a command with the executable file\n\
- # name as an extra leading argument.\n\
- movl _dl_skip_args(%rip), %eax\n\
- # Pop the original argument count.\n\
+ # Read the original argument count.\n\
movl (%rsp), %edx\n\
- # Adjust the stack pointer to skip _dl_skip_args words.\n\
- lea 4(%rsp,%rax,4), %esp\n\
- # Subtract _dl_skip_args from argc.\n\
- subl %eax, %edx\n\
- # Push argc back on the stack.\n\
- subl $4, %esp\n\
- movl %edx, (%rsp)\n\
# Call _dl_init (struct link_map *main_map, int argc, char **argv, char **env)\n\
# argc -> rsi\n\
movl %edx, %esi\n\