OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "native_client/src/trusted/plugin/pnacl_coordinator.h" | 5 #include "native_client/src/trusted/plugin/pnacl_coordinator.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "native_client/src/include/portability_io.h" | 10 #include "native_client/src/include/portability_io.h" |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 nacl::string GeneratedObjectFileName() { | 347 nacl::string GeneratedObjectFileName() { |
348 return nacl::string("___PNACL_GENERATED"); | 348 return nacl::string("___PNACL_GENERATED"); |
349 } | 349 } |
350 | 350 |
351 nacl::string ResourceBaseUrl() { | 351 nacl::string ResourceBaseUrl() { |
352 nacl::string sandbox_isa = GetSandboxISA(); | 352 nacl::string sandbox_isa = GetSandboxISA(); |
353 nacl::string base_url = "pnacl_support/" + sandbox_isa + "/"; | 353 nacl::string base_url = "pnacl_support/" + sandbox_isa + "/"; |
354 return base_url; | 354 return base_url; |
355 } | 355 } |
356 | 356 |
357 string_vector LinkResources(bool withGenerated) { | 357 string_vector LinkResources(const nacl::string& sandbox_isa, |
| 358 bool withGenerated) { |
358 string_vector results; | 359 string_vector results; |
359 // NOTE: order of items == link order. | 360 // NOTE: order of items == link order. |
| 361 if (sandbox_isa.compare("x86-64") == 0) { |
| 362 results.push_back("libpnacl_irt_shim.a"); |
| 363 } |
360 results.push_back("crtbegin.o"); | 364 results.push_back("crtbegin.o"); |
361 if (withGenerated) { | 365 if (withGenerated) { |
362 results.push_back(GeneratedObjectFileName()); | 366 results.push_back(GeneratedObjectFileName()); |
363 } | 367 } |
364 results.push_back("libcrt_platform.a"); | 368 results.push_back("libcrt_platform.a"); |
365 results.push_back("libgcc.a"); | 369 results.push_back("libgcc.a"); |
366 results.push_back("libgcc_eh.a"); | 370 results.push_back("libgcc_eh.a"); |
367 results.push_back("crtend.o"); | 371 results.push_back("crtend.o"); |
368 return results; | 372 return results; |
369 } | 373 } |
(...skipping 27 matching lines...) Expand all Loading... |
397 // TODO(jvoung): Be able to handle the dynamic linking flags too, | 401 // TODO(jvoung): Be able to handle the dynamic linking flags too, |
398 // and don't hardcode so much here. | 402 // and don't hardcode so much here. |
399 string_vector flags; | 403 string_vector flags; |
400 nacl::string sandbox_isa = GetSandboxISA(); | 404 nacl::string sandbox_isa = GetSandboxISA(); |
401 flags.push_back("-nostdlib"); | 405 flags.push_back("-nostdlib"); |
402 flags.push_back("-m"); | 406 flags.push_back("-m"); |
403 if (sandbox_isa.compare("x86-32") == 0) { | 407 if (sandbox_isa.compare("x86-32") == 0) { |
404 flags.push_back("elf_nacl"); | 408 flags.push_back("elf_nacl"); |
405 } else if (sandbox_isa.compare("x86-64") == 0) { | 409 } else if (sandbox_isa.compare("x86-64") == 0) { |
406 flags.push_back("elf64_nacl"); | 410 flags.push_back("elf64_nacl"); |
| 411 flags.push_back("-entry=_pnacl_wrapper_start"); |
407 } else if (sandbox_isa.compare("arm") == 0) { | 412 } else if (sandbox_isa.compare("arm") == 0) { |
408 flags.push_back("armelf_nacl"); | 413 flags.push_back("armelf_nacl"); |
409 } else { | 414 } else { |
410 AbortLinkThread(p, | 415 AbortLinkThread(p, |
411 "PnaclCoordinator linker unhandled ISA " + | 416 "PnaclCoordinator linker unhandled ISA " + |
412 sandbox_isa + "."); | 417 sandbox_isa + "."); |
413 } | 418 } |
414 | 419 |
415 for (string_vector::iterator i = flags.begin(), e = flags.end(); | 420 for (string_vector::iterator i = flags.begin(), e = flags.end(); |
416 i != e; ++i) { | 421 i != e; ++i) { |
417 const nacl::string& flag = *i; | 422 const nacl::string& flag = *i; |
418 if (coordinator->SubprocessesShouldDie()) { | 423 if (coordinator->SubprocessesShouldDie()) { |
419 NaClThreadExit(1); | 424 NaClThreadExit(1); |
420 } | 425 } |
421 SrpcParams dummy_params; | 426 SrpcParams dummy_params; |
422 if (!PnaclSrpcLib::InvokeSrpcMethod(browser_interface, | 427 if (!PnaclSrpcLib::InvokeSrpcMethod(browser_interface, |
423 ld_subprocess, | 428 ld_subprocess, |
424 "AddArg", | 429 "AddArg", |
425 "C", | 430 "C", |
426 &dummy_params, | 431 &dummy_params, |
427 flag.c_str())) { | 432 flag.c_str())) { |
428 AbortLinkThread(p, | 433 AbortLinkThread(p, |
429 "PnaclCoordinator linker AddArg(" + flag + | 434 "PnaclCoordinator linker AddArg(" + flag + |
430 ") failed."); | 435 ") failed."); |
431 } | 436 } |
432 } | 437 } |
433 | 438 |
434 //// Files. | 439 //// Files. |
435 string_vector files = LinkResources(true); | 440 string_vector files = LinkResources(sandbox_isa, true); |
436 PnaclResources* resources = coordinator->resources(); | 441 PnaclResources* resources = coordinator->resources(); |
437 for (string_vector::iterator i = files.begin(), e = files.end(); | 442 for (string_vector::iterator i = files.begin(), e = files.end(); |
438 i != e; ++i) { | 443 i != e; ++i) { |
439 const nacl::string& link_file = *i; | 444 const nacl::string& link_file = *i; |
440 if (coordinator->SubprocessesShouldDie()) { | 445 if (coordinator->SubprocessesShouldDie()) { |
441 NaClThreadExit(1); | 446 NaClThreadExit(1); |
442 } | 447 } |
443 // Add as argument. | 448 // Add as argument. |
444 SrpcParams dummy_params; | 449 SrpcParams dummy_params; |
445 if (!PnaclSrpcLib::InvokeSrpcMethod(browser_interface, | 450 if (!PnaclSrpcLib::InvokeSrpcMethod(browser_interface, |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 | 617 |
613 translation_unit_.reset(new PnaclTranslationUnit(this)); | 618 translation_unit_.reset(new PnaclTranslationUnit(this)); |
614 | 619 |
615 // When resources loading completes, this causes the pexe download. | 620 // When resources loading completes, this causes the pexe download. |
616 pp::CompletionCallback resources_cb = | 621 pp::CompletionCallback resources_cb = |
617 callback_factory_.NewCallback(&PnaclCoordinator::ResourcesDidLoad, | 622 callback_factory_.NewCallback(&PnaclCoordinator::ResourcesDidLoad, |
618 pexe_url, | 623 pexe_url, |
619 translation_unit_.get()); | 624 translation_unit_.get()); |
620 resources_->AddResourceUrl(llc_url_); | 625 resources_->AddResourceUrl(llc_url_); |
621 resources_->AddResourceUrl(ld_url_); | 626 resources_->AddResourceUrl(ld_url_); |
622 string_vector link_resources = LinkResources(false); | 627 string_vector link_resources = LinkResources(GetSandboxISA(), false); |
623 for (string_vector::iterator | 628 for (string_vector::iterator |
624 i = link_resources.begin(), e = link_resources.end(); | 629 i = link_resources.begin(), e = link_resources.end(); |
625 i != e; | 630 i != e; |
626 ++i) { | 631 ++i) { |
627 resources_->AddResourceUrl(*i); | 632 resources_->AddResourceUrl(*i); |
628 } | 633 } |
629 resources_->RunWhenAllLoaded(resources_cb); | 634 resources_->RunWhenAllLoaded(resources_cb); |
630 resources_->StartDownloads(); | 635 resources_->StartDownloads(); |
631 } | 636 } |
632 | 637 |
633 } // namespace plugin | 638 } // namespace plugin |
OLD | NEW |