public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] elf: Fix tst-relro-symbols.py argument passing
@ 2022-12-14 21:20 Adhemerval Zanella
  2022-12-14 21:45 ` Florian Weimer
  0 siblings, 1 reply; 3+ messages in thread
From: Adhemerval Zanella @ 2022-12-14 21:20 UTC (permalink / raw)
  To: libc-alpha, Florian Weimer

Current scheme only consideres the first argument for both --required
and --optional, where the idea is to append a new item.

Checked on x86_64-linux-gnu.
---
 elf/tst-relro-symbols.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/elf/tst-relro-symbols.py b/elf/tst-relro-symbols.py
index 368ea3349f..41e87b37ea 100644
--- a/elf/tst-relro-symbols.py
+++ b/elf/tst-relro-symbols.py
@@ -56,10 +56,10 @@ def get_parser():
     """Return an argument parser for this script."""
     parser = argparse.ArgumentParser(description=__doc__)
     parser.add_argument('object', help='path to object file to check')
-    parser.add_argument('--required', metavar='NAME', default=(),
-                        help='required symbol names', nargs='*')
-    parser.add_argument('--optional', metavar='NAME', default=(),
-                        help='required symbol names', nargs='*')
+    parser.add_argument('--required', metavar='NAME', action='append',
+                        help='required symbol names')
+    parser.add_argument('--optional', metavar='NAME', action='append',
+                        help='required symbol names')
     return parser
 
 def main(argv):
-- 
2.34.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] elf: Fix tst-relro-symbols.py argument passing
  2022-12-14 21:20 [PATCH] elf: Fix tst-relro-symbols.py argument passing Adhemerval Zanella
@ 2022-12-14 21:45 ` Florian Weimer
  2022-12-14 22:22   ` Adhemerval Zanella Netto
  0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2022-12-14 21:45 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> Current scheme only consideres the first argument for both --required
> and --optional, where the idea is to append a new item.
>
> Checked on x86_64-linux-gnu.
> ---
>  elf/tst-relro-symbols.py | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/elf/tst-relro-symbols.py b/elf/tst-relro-symbols.py
> index 368ea3349f..41e87b37ea 100644
> --- a/elf/tst-relro-symbols.py
> +++ b/elf/tst-relro-symbols.py
> @@ -56,10 +56,10 @@ def get_parser():
>      """Return an argument parser for this script."""
>      parser = argparse.ArgumentParser(description=__doc__)
>      parser.add_argument('object', help='path to object file to check')
> -    parser.add_argument('--required', metavar='NAME', default=(),
> -                        help='required symbol names', nargs='*')
> -    parser.add_argument('--optional', metavar='NAME', default=(),
> -                        help='required symbol names', nargs='*')
> +    parser.add_argument('--required', metavar='NAME', action='append',
> +                        help='required symbol names')
> +    parser.add_argument('--optional', metavar='NAME', action='append',
> +                        help='required symbol names')
>      return parser
>  
>  def main(argv):

Ugh, right, that's a bug.  But your fix does not seem to work, either:

$ python3 elf/tst-relro-symbols.py --required=undefined --required=_rtld_global_ro   /lib64/ld-linux-x86-64.so.2 
Traceback (most recent call last):
  File "…/src/gnu/glibc/git/elf/tst-relro-symbols.py", line 137, in <module>
    main(sys.argv[1:])
  File "…/src/gnu/glibc/git/elf/tst-relro-symbols.py", line 73, in main
    optional_symbols = frozenset([sym.encode('UTF-8')
                                 ^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable

Thanks,
Florian


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] elf: Fix tst-relro-symbols.py argument passing
  2022-12-14 21:45 ` Florian Weimer
@ 2022-12-14 22:22   ` Adhemerval Zanella Netto
  0 siblings, 0 replies; 3+ messages in thread
From: Adhemerval Zanella Netto @ 2022-12-14 22:22 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 14/12/22 18:45, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> Current scheme only consideres the first argument for both --required
>> and --optional, where the idea is to append a new item.
>>
>> Checked on x86_64-linux-gnu.
>> ---
>>  elf/tst-relro-symbols.py | 8 ++++----
>>  1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/elf/tst-relro-symbols.py b/elf/tst-relro-symbols.py
>> index 368ea3349f..41e87b37ea 100644
>> --- a/elf/tst-relro-symbols.py
>> +++ b/elf/tst-relro-symbols.py
>> @@ -56,10 +56,10 @@ def get_parser():
>>      """Return an argument parser for this script."""
>>      parser = argparse.ArgumentParser(description=__doc__)
>>      parser.add_argument('object', help='path to object file to check')
>> -    parser.add_argument('--required', metavar='NAME', default=(),
>> -                        help='required symbol names', nargs='*')
>> -    parser.add_argument('--optional', metavar='NAME', default=(),
>> -                        help='required symbol names', nargs='*')
>> +    parser.add_argument('--required', metavar='NAME', action='append',
>> +                        help='required symbol names')
>> +    parser.add_argument('--optional', metavar='NAME', action='append',
>> +                        help='required symbol names')
>>      return parser
>>  
>>  def main(argv):
> 
> Ugh, right, that's a bug.  But your fix does not seem to work, either:
> 
> $ python3 elf/tst-relro-symbols.py --required=undefined --required=_rtld_global_ro   /lib64/ld-linux-x86-64.so.2 
> Traceback (most recent call last):
>   File "…/src/gnu/glibc/git/elf/tst-relro-symbols.py", line 137, in <module>
>     main(sys.argv[1:])
>   File "…/src/gnu/glibc/git/elf/tst-relro-symbols.py", line 73, in main
>     optional_symbols = frozenset([sym.encode('UTF-8')
>                                  ^^^^^^^^^^^^^^^^^^^^
> TypeError: 'NoneType' object is not iterable
> 

It does work for tst-relro-libc.out, although it would be good to allow either
empty --required or --optional.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-14 22:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-14 21:20 [PATCH] elf: Fix tst-relro-symbols.py argument passing Adhemerval Zanella
2022-12-14 21:45 ` Florian Weimer
2022-12-14 22:22   ` Adhemerval Zanella Netto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).