diff mbox series

elf: Support lld-style link map for librtld.map

Message ID 20200313020955.rcx63wkdsi6bodd4@google.com
State New
Headers show
Series elf: Support lld-style link map for librtld.map | expand

Commit Message

Fāng-ruì Sòng March 13, 2020, 2:09 a.m. UTC
GNU ld and gold's -Map include a line like:

  path/to/build/libc_pic.a(check_fds.os)

lld -Map does not have the archive member list, but we can still derive the
members from the following output

             VMA              LMA     Size Align Out     In      Symbol
...
           1a1c0            1a1c0       e2    16         path/to/build/libc_pic.a(check_fds.os):(.text)

---
 elf/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Adhemerval Zanella April 7, 2020, 8:31 p.m. UTC | #1
On 12/03/2020 23:09, Fangrui Song wrote:
> GNU ld and gold's -Map include a line like:
> 
>   path/to/build/libc_pic.a(check_fds.os)
> 
> lld -Map does not have the archive member list, but we can still derive the
> members from the following output
> 
>              VMA              LMA     Size Align Out     In      Symbol
> ...
>            1a1c0            1a1c0       e2    16         path/to/build/libc_pic.a(check_fds.os):(.text)

The new regex will match more entries, but I think it is ok.

LGTM, thanks.

> 
> ---
>  elf/Makefile | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/elf/Makefile b/elf/Makefile
> index da689a2c7b..b035407112 100644
> --- a/elf/Makefile
> +++ b/elf/Makefile
> @@ -512,9 +512,10 @@ $(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
>  	rm -f $@.o
>  	mv -f $@T $@
>  
> +# For lld, skip preceding addresses and values before matching the archive and the member.
>  $(objpfx)librtld.mk: $(objpfx)librtld.map Makefile
>  	LC_ALL=C \
> -	sed -n 's@^$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
> +	sed -n 's@^[0-9a-f ]*$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
>  	    $< | \
>  	while read lib file; do \
>  	  case $$lib in \
>
Fāng-ruì Sòng April 20, 2020, 7:44 p.m. UTC | #2
On 2020-04-07, Adhemerval Zanella wrote:
>On 12/03/2020 23:09, Fangrui Song wrote:
>> GNU ld and gold's -Map include a line like:
>>
>>   path/to/build/libc_pic.a(check_fds.os)
>>
>> lld -Map does not have the archive member list, but we can still derive the
>> members from the following output
>>
>>              VMA              LMA     Size Align Out     In      Symbol
>> ...
>>            1a1c0            1a1c0       e2    16         path/to/build/libc_pic.a(check_fds.os):(.text)
>
>The new regex will match more entries, but I think it is ok.
>
>LGTM, thanks.
>
>>
>> ---
>>  elf/Makefile | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/elf/Makefile b/elf/Makefile
>> index da689a2c7b..b035407112 100644
>> --- a/elf/Makefile
>> +++ b/elf/Makefile
>> @@ -512,9 +512,10 @@ $(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
>>  	rm -f $@.o
>>  	mv -f $@T $@
>>
>> +# For lld, skip preceding addresses and values before matching the archive and the member.
>>  $(objpfx)librtld.mk: $(objpfx)librtld.map Makefile
>>  	LC_ALL=C \
>> -	sed -n 's@^$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
>> +	sed -n 's@^[0-9a-f ]*$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
>>  	    $< | \
>>  	while read lib file; do \
>>  	  case $$lib in \
>>

Adhemerval, can you (or another maintainer) commit this on my behalf?
We havn't heard objections so far.
Adhemerval Zanella April 20, 2020, 8:18 p.m. UTC | #3
On 20/04/2020 16:44, Fangrui Song wrote:
> On 2020-04-07, Adhemerval Zanella wrote:
>> On 12/03/2020 23:09, Fangrui Song wrote:
>>> GNU ld and gold's -Map include a line like:
>>>
>>>   path/to/build/libc_pic.a(check_fds.os)
>>>
>>> lld -Map does not have the archive member list, but we can still derive the
>>> members from the following output
>>>
>>>              VMA              LMA     Size Align Out     In      Symbol
>>> ...
>>>            1a1c0            1a1c0       e2    16         path/to/build/libc_pic.a(check_fds.os):(.text)
>>
>> The new regex will match more entries, but I think it is ok.
>>
>> LGTM, thanks.
>>
>>>
>>> ---
>>>  elf/Makefile | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/elf/Makefile b/elf/Makefile
>>> index da689a2c7b..b035407112 100644
>>> --- a/elf/Makefile
>>> +++ b/elf/Makefile
>>> @@ -512,9 +512,10 @@ $(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
>>>      rm -f $@.o
>>>      mv -f $@T $@
>>>
>>> +# For lld, skip preceding addresses and values before matching the archive and the member.
>>>  $(objpfx)librtld.mk: $(objpfx)librtld.map Makefile
>>>      LC_ALL=C \
>>> -    sed -n 's@^$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
>>> +    sed -n 's@^[0-9a-f ]*$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
>>>          $< | \
>>>      while read lib file; do \
>>>        case $$lib in \
>>>
> 
> Adhemerval, can you (or another maintainer) commit this on my behalf?
> We havn't heard objections so far.

I will do it.
diff mbox series

Patch

diff --git a/elf/Makefile b/elf/Makefile
index da689a2c7b..b035407112 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -512,9 +512,10 @@  $(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
 	rm -f $@.o
 	mv -f $@T $@
 
+# For lld, skip preceding addresses and values before matching the archive and the member.
 $(objpfx)librtld.mk: $(objpfx)librtld.map Makefile
 	LC_ALL=C \
-	sed -n 's@^$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
+	sed -n 's@^[0-9a-f ]*$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
 	    $< | \
 	while read lib file; do \
 	  case $$lib in \