Open Bug 1459314 Opened 7 years ago Updated 5 months ago

NSS is missing every(?) public symbol when -fvisibility=hidden is specified

Categories

(Firefox Build System :: General, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: tjr, Unassigned)

References

(Blocks 2 open bugs)

Details

Attachments

(2 files, 1 obsolete file)

Whole bunch of errors of the form > 0:07.58 /builds/worker/my-workspace/build/src/clang/bin/ld.lld: error: undefined symbol: NSS_Initialize > 0:07.58 >>> referenced by mar_sign.c:37 (/builds/worker/my-workspace/build/src/modules/libmar/sign/mar_sign.c:37) > 0:07.58 >>> lto.tmp:(main) > 0:07.58 /builds/worker/my-workspace/build/src/clang/bin/ld.lld: error: undefined symbol: PK11_FindCertFromNickname > 0:07.58 >>> referenced by mar.c:365 (/builds/worker/my-workspace/build/src/modules/libmar/tool/mar.c:365) > 0:07.58 >>> lto.tmp:(main) I compared a LTO build with a LTO+CFI build, taking NSS_Initialize as an arbitrary example. Sure enough, it's missing in the CFI build: https://www.diffchecker.com/QhA60FqE
This does not occur with -fsanitize=cfi-cast-strict but it does occur with -fsanitize=cfi-icall. Neither of these require -fvisibility, so the error apparently does not related to that flag.
Are the undefined symbols always (for lack of knowing the elf term) "dllexport" functions?
Blocks: 1465549
No longer blocks: cfi
No longer a problem. Maybe upgrading clang solved it?
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WORKSFORME
Status: RESOLVED → UNCONFIRMED
Ever confirmed: false
Resolution: WORKSFORME → ---
Status: UNCONFIRMED → NEW
Ever confirmed: true
This is because the functions that don't get emitted to the DSO need an __attribute__((visibility("default"))) annotation
(In reply to Tom Ritter [:tjr] from comment #5) > This is because the functions that don't get emitted to the DSO need an > __attribute__((visibility("default"))) annotation That doesn't sound right.
(In reply to Mike Hommey [:glandium] from comment #6) > (In reply to Tom Ritter [:tjr] from comment #5) > > This is because the functions that don't get emitted to the DSO need an > > __attribute__((visibility("default"))) annotation > > That doesn't sound right. Ah... I didn't mention this; but this error occurs when adding -fvisibility=hidden to the build and linking command line tools to nss3 like signmar. Does that sound any better?
Flags: needinfo?(mh+mozilla)
Why are you adding -fvisibility=hidden to the build?
Flags: needinfo?(mh+mozilla)
(In reply to Mike Hommey [:glandium] from comment #8) > Why are you adding -fvisibility=hidden to the build? Some value of -fvisibility is required for cfi-vcall. fvisibility=hidden is the generally recommended option. https://clang.llvm.org/docs/ControlFlowIntegrity.html
Flags: needinfo?(mh+mozilla)
Except we set visibility in other ways. Which is why adding -fvisibility=hidden busts NSS. And does nothing useful on the rest on the build.
Flags: needinfo?(mh+mozilla)
Blocks: cfi-vcall
No longer blocks: 1465549
Summary: CFI build is missing symbols → NSS is missing every(?) public symbol when -fvisibility=hidden is specified
Regardless, fvisibility is a required compiler flag for CFI vcall to compile. I've attached a horrible patch that adds the attribute to the public NSS functions, and allows a browser with vcall to compile and run. We may need to add the appropriate attribute (as indicated in this patch); but another option may include setting -fvisibility=default for NSS (although I think this will result in no CFI protection there).
Attachment #8995662 - Attachment is obsolete: true
(In reply to Tom Ritter [:tjr] from comment #9) > (In reply to Mike Hommey [:glandium] from comment #8) > > Why are you adding -fvisibility=hidden to the build? > > Some value of -fvisibility is required for cfi-vcall. fvisibility=hidden is > the generally recommended option. > https://clang.llvm.org/docs/ControlFlowIntegrity.html I'll have to insist that you don't use -fvisibility=hidden. What the page says is that the build needs to have visibility hidden associated with non public stuff so that CFI can work. That already *is* happening with the normal build. You don't need to pass -fvisibility=hidden to have symbols with hidden visibility in the build.
(In reply to Mike Hommey [:glandium] from comment #14) > (In reply to Tom Ritter [:tjr] from comment #9) > > (In reply to Mike Hommey [:glandium] from comment #8) > > > Why are you adding -fvisibility=hidden to the build? > > > > Some value of -fvisibility is required for cfi-vcall. fvisibility=hidden is > > the generally recommended option. > > https://clang.llvm.org/docs/ControlFlowIntegrity.html > > I'll have to insist that you don't use -fvisibility=hidden. What the page > says is that the build needs to have visibility hidden associated with non > public stuff so that CFI can work. That already *is* happening with the > normal build. You don't need to pass -fvisibility=hidden to have symbols > with hidden visibility in the build. I will have to figure out what I need to change in the compiler to get it to accept vcall without specifying the compiler parameter. Right now; the direct milestone for CFI is to get performance numbers on Windows acceptable; so I'll be using this local workaround for the time being until we know for certain we can land CFI at all; at which point cleaning up the ugly messes like this one will be the priority (and blockers for landing).
That the compiler requires -fvisibility=hidden is even worse on Windows, where it has no meaning: everything is hidden by default, unless __declspec(dllexport).
Version: Version 3 → 3 Branch
Assignee: tom → nobody
Type: defect → enhancement
Priority: -- → P3
Version: 3 Branch → Trunk
Severity: normal → S3

The following patches are waiting for review from an inactive reviewer:

ID Title Author Reviewer Status
D3041 Bug 1459314 Add default visibility to a whole bunch of stuff in nss and sqlite to resolve missing symbol errors with cfi-vcall r=Alex_Gaynor tjr Alex_Gaynor: Inactive
D3419 Bug 1459314 Add default visibility to a whole bunch of stuff in nss and sqlite to resolve missing symbol errors with cfi-vcall r=Alex_Gaynor tjr Alex_Gaynor: Inactive

:tjr, could you please find another reviewer or abandon the patch if it is no longer relevant?

For more information, please visit auto_nag documentation.

Flags: needinfo?(tom)
Flags: needinfo?(tom)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: