Commit c0bf7c29 authored by hamaji@chromium.org's avatar hamaji@chromium.org

Non-SFI NaCl: Fix browser_tests based on libc_free.c

There were two issues with clang:

- Clang emits .data.rel.ro.local for local struct values with
  an initializer, which lets the linker to emit a few
  relocation info.
- In debug build, clang uses memcpy to copy a structure with
  five members. Neither -fno-builtin nor -ffreestanding did
  not prevent this issue.
- In release build, clang translates for-loop based zero copy
  to memset.

This patch initializes all structures without initializers
or copy. This patch works with GYP_DEFINES=clang=0.

To make sure we will not add memcpy or something in future,
we will build libc_free.nexe with -Wl,--no-undefined.

This also reverts

https://codereview.chromium.org/386543002

to enable the disabled tests.

BUG=392768
TEST=./out/Debug/browser_tests --gtest_filter='*NonSfi*Messaging*'

Review URL: https://codereview.chromium.org/381883002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282697 0039d316-1c4b-4281-b951-d872f2087c98
parent 7cfd7fd8
...@@ -1139,6 +1139,11 @@ ...@@ -1139,6 +1139,11 @@
# Stack-Smashing protector does not work with libc-free context. # Stack-Smashing protector does not work with libc-free context.
'-fno-stack-protector', '-fno-stack-protector',
# Optimizers may translate the original code to code which
# requires builtin functions and/or relocations. Specifically,
# the LLVM's optimizer translates for-loop based zero
# clear to memset.
'-O0',
], ],
'cflags!': [ 'cflags!': [
# We filter these out because release_extra_cflags or another # We filter these out because release_extra_cflags or another
...@@ -1148,10 +1153,14 @@ ...@@ -1148,10 +1153,14 @@
'-fstack-protector-all', '-fstack-protector-all',
'-fprofile-generate', '-fprofile-generate',
'-finstrument-functions', '-finstrument-functions',
'-O2',
], ],
'ldflags': [ 'ldflags': [
'-nostdlib', '-nostdlib',
'-shared', '-shared',
# This binary cannot relocate itself, so we should have no
# undefined references left.
'-Wl,--no-undefined',
], ],
'ldflags!': [ 'ldflags!': [
# Explicitly remove the -pthread flag to avoid a link time warning. # Explicitly remove the -pthread flag to avoid a link time warning.
......
...@@ -221,24 +221,17 @@ void _start(uintptr_t info[]) { ...@@ -221,24 +221,17 @@ void _start(uintptr_t info[]) {
/* This is local as a workaround to avoid having to apply /* This is local as a workaround to avoid having to apply
* relocations to global variables. */ * relocations to global variables. */
struct PP_StartFunctions start_funcs = { struct PP_StartFunctions start_funcs;
MyPPP_InitializeModule, start_funcs.PPP_InitializeModule = MyPPP_InitializeModule;
MyPPP_ShutdownModule, start_funcs.PPP_ShutdownModule = MyPPP_ShutdownModule;
MyPPP_GetInterface, start_funcs.PPP_GetInterface = MyPPP_GetInterface;
}; /* Similarly, initialize some global variables, avoiding relocations. */
/* Similarly, initialise some global variables, avoiding relocations. */ ppp_instance.DidCreate = DidCreate;
struct PPP_Instance_1_0 local_ppp_instance = { ppp_instance.DidDestroy = DidDestroy;
DidCreate, ppp_instance.DidChangeView = DidChangeView;
DidDestroy, ppp_instance.DidChangeFocus = DidChangeFocus;
DidChangeView, ppp_instance.HandleDocumentLoad = HandleDocumentLoad;
DidChangeFocus, ppp_messaging.HandleMessage = HandleMessage;
HandleDocumentLoad,
};
ppp_instance = local_ppp_instance;
struct PPP_Messaging_1_0 local_ppp_messaging = {
HandleMessage,
};
ppp_messaging = local_ppp_messaging;
ppapihook.ppapi_start(&start_funcs); ppapihook.ppapi_start(&start_funcs);
......
...@@ -33,24 +33,15 @@ namespace { ...@@ -33,24 +33,15 @@ namespace {
# define MAYBE_SysconfNprocessorsOnln SysconfNprocessorsOnln # define MAYBE_SysconfNprocessorsOnln SysconfNprocessorsOnln
#endif #endif
// crbug.com/392768
#if defined(OS_LINUX)
# define MAYBE_Messaging DISABLED_Messaging
# define MAYBE_Irt DISABLED_Irt
#else
# define MAYBE_Messaging MAYBE_NONSFI(Messaging)
# define MAYBE_Irt MAYBE_NONSFI(Irt)
#endif
NACL_BROWSER_TEST_F(NaClBrowserTest, SimpleLoad, { NACL_BROWSER_TEST_F(NaClBrowserTest, SimpleLoad, {
RunLoadTest(FILE_PATH_LITERAL("nacl_load_test.html")); RunLoadTest(FILE_PATH_LITERAL("nacl_load_test.html"));
}) })
IN_PROC_BROWSER_TEST_F(NaClBrowserTestNonSfiMode, MAYBE_Messaging) { IN_PROC_BROWSER_TEST_F(NaClBrowserTestNonSfiMode, MAYBE_NONSFI(Messaging)) {
RunLoadTest(FILE_PATH_LITERAL("libc_free.html")); RunLoadTest(FILE_PATH_LITERAL("libc_free.html"));
} }
IN_PROC_BROWSER_TEST_F(NaClBrowserTestNonSfiMode, MAYBE_Irt) { IN_PROC_BROWSER_TEST_F(NaClBrowserTestNonSfiMode, MAYBE_NONSFI(Irt)) {
RunNaClIntegrationTest(FILE_PATH_LITERAL("irt_test.html")); RunNaClIntegrationTest(FILE_PATH_LITERAL("irt_test.html"));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment