From 0589a2a209f3b975dd6a9fa7fba5ac7b64e4285e Mon Sep 17 00:00:00 2001 From: Milad Farazmand Date: Wed, 19 Aug 2020 23:54:43 +0000 Subject: [PATCH] AIX: Fix DeclareSymbolGlobal on AIX Port 929dd3748e9e29b8c858fa2e587187b84cdcfeac Original Commit Message: When CFI is enabled this adds a check against this list whenever a new return address must be set in a deoptimized frame, as a mitigation for ROP attacks. The list is known at linking time so that its content and the pointer to it can be stored in a read-only memory section. The check is performed in the signing function, which is no longer generic, as well as when setting the current pc of the frame. Since the pc is now only signed when setting the caller's pc, there is no need for ReplaceContext anymore. R=salome.thirot@arm.com, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com BUG= LOG=N Change-Id: I5005096811c289707e2d080477c60ae2ed4bf38b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2365372 Reviewed-by: Jakob Gruber Reviewed-by: Ross McIlroy Commit-Queue: Milad Farazmand Cr-Commit-Position: refs/heads/master@{#69502} --- .../embedded/platform-embedded-file-writer-aix.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/snapshot/embedded/platform-embedded-file-writer-aix.cc b/src/snapshot/embedded/platform-embedded-file-writer-aix.cc index cb3f977afe7..1c823ef421d 100644 --- a/src/snapshot/embedded/platform-embedded-file-writer-aix.cc +++ b/src/snapshot/embedded/platform-embedded-file-writer-aix.cc @@ -57,7 +57,9 @@ void PlatformEmbeddedFileWriterAIX::DeclarePointerToSymbol(const char* name, } void PlatformEmbeddedFileWriterAIX::DeclareSymbolGlobal(const char* name) { - fprintf(fp_, ".globl %s\n", name); + // These symbols are not visible outside of the final binary, this allows for + // reduced binary size, and less work for the dynamic linker. + fprintf(fp_, ".globl %s, hidden\n", name); } void PlatformEmbeddedFileWriterAIX::AlignToCodeAlignment() { @@ -73,6 +75,9 @@ void PlatformEmbeddedFileWriterAIX::Comment(const char* string) { } void PlatformEmbeddedFileWriterAIX::DeclareLabel(const char* name) { + // .global is required on AIX, if the label is used/referenced in another file + // later to be linked. + fprintf(fp_, ".globl %s\n", name); fprintf(fp_, "%s:\n", name); } @@ -85,7 +90,9 @@ void PlatformEmbeddedFileWriterAIX::SourceInfo(int fileid, const char* filename, void PlatformEmbeddedFileWriterAIX::DeclareFunctionBegin(const char* name, uint32_t size) { Newline(); - DeclareSymbolGlobal(name); + if (ENABLE_CONTROL_FLOW_INTEGRITY_BOOL) { + DeclareSymbolGlobal(name); + } fprintf(fp_, ".csect %s[DS]\n", name); // function descriptor fprintf(fp_, "%s:\n", name); fprintf(fp_, ".llong .%s, 0, 0\n", name);