This is an archive of the discontinued LLVM Phabricator instance.

[llvm-ar] Fix for handling thin archive with SYM64 and a test case for it
ClosedPublic

Authored by Ramesh on Aug 2 2021, 8:43 PM.

Details

Summary

WHen thin archives are created which have symbol table of type SYM64 then all the tools will not work since they cannot read the files properly.
One can reproduce the problem as follows:

  1. Take a hello world program and create an archive out of it. The SYM64_THRESHOLD=0 will force the generation of SYM64 symbol table. clang -c hello.cpp SYM64_THRESHOLD=0 llvm-ar crsT mylib.a hello.o
  2. Now try to use any of the tools on this mylib.a and it will fail. llvm-nm -M mylib.a

THis fix will eliminate these failures. A regression test is created in llvm/test/Object/archive-symtab.test

Diff Detail

Event Timeline

Ramesh created this revision.Aug 2 2021, 8:43 PM
Ramesh requested review of this revision.Aug 2 2021, 8:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2021, 8:43 PM
Ramesh retitled this revision from Fix for handling thin archive with SYM64 and a test case for it to [llvm-ar] Fix for handling thin archive with SYM64 and a test case for it.Aug 4 2021, 8:40 AM
hoy added a reviewer: MaskRay.Aug 4 2021, 8:45 AM

LG

llvm/test/Object/archive-symtab.test
55

-M => --print-armap

-M was inappropriately added when -s was taken by Darwin nm. -M will be removed and should not be used.

68

drop unrelated change

Ramesh marked an inline comment as done.Aug 4 2021, 7:56 PM
Ramesh added inline comments.
llvm/test/Object/archive-symtab.test
55

There are a number of other tests which are using this option still - what needs to be done about them?

68

Will fix it.

Ramesh accepted this revision.Aug 4 2021, 10:22 PM
Ramesh marked an inline comment as done.
This revision is now accepted and ready to land.Aug 4 2021, 10:22 PM
Ramesh updated this revision to Diff 364505.Aug 5 2021, 9:21 AM

Address reviwer comments

MaskRay accepted this revision.Aug 5 2021, 9:44 AM

Thanks! I migrated these -M to --print-armap