Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 427704
Collapse All | Expand All

(-)a/elfcpp/elfcpp.h (-1 / +16 lines)
Lines 479-484 enum PT Link Here
479
  PT_GNU_STACK = 0x6474e551,
479
  PT_GNU_STACK = 0x6474e551,
480
  // Read only after relocation.
480
  // Read only after relocation.
481
  PT_GNU_RELRO = 0x6474e552,
481
  PT_GNU_RELRO = 0x6474e552,
482
  // PaX flags
483
  PT_PAX_FLAGS = 0x65041580,
482
  // Platform architecture compatibility information
484
  // Platform architecture compatibility information
483
  PT_ARM_ARCHEXT = 0x70000000,
485
  PT_ARM_ARCHEXT = 0x70000000,
484
  // Exception unwind tables
486
  // Exception unwind tables
Lines 499-505 enum PF Link Here
499
  PF_W = 0x2,
501
  PF_W = 0x2,
500
  PF_R = 0x4,
502
  PF_R = 0x4,
501
  PF_MASKOS = 0x0ff00000,
503
  PF_MASKOS = 0x0ff00000,
502
  PF_MASKPROC = 0xf0000000
504
  PF_MASKPROC = 0xf0000000,
505
  /* Flags to control PaX behavior. */
506
  PF_PAGEEXEC   = (1 << 4),	/* Enable  PAGEEXEC */
507
  PF_NOPAGEEXEC = (1 << 5),	/* Disable PAGEEXEC */
508
  PF_SEGMEXEC   = (1 << 6),	/* Enable  SEGMEXEC */
509
  PF_NOSEGMEXEC = (1 << 7),	/* Disable SEGMEXEC */
510
  PF_MPROTECT   = (1 << 8),	/* Enable  MPROTECT */
511
  PF_NOMPROTECT = (1 << 9),	/* Disable MPROTECT */
512
  PF_RANDEXEC   = (1 << 10),	/* Enable  RANDEXEC */
513
  PF_NORANDEXEC = (1 << 11),	/* Disable RANDEXEC */
514
  PF_EMUTRAMP   = (1 << 12),	/* Enable  EMUTRAMP */
515
  PF_NOEMUTRAMP = (1 << 13),	/* Disable EMUTRAMP */
516
  PF_RANDMMAP   = (1 << 14),	/* Enable  RANDMMAP */
517
  PF_NORANDMMAP = (1 << 15)	/* Disable RANDMMAP */
503
};
518
};
504
519
505
// Symbol binding from Sym st_info field.
520
// Symbol binding from Sym st_info field.
(-)a/gold/layout.cc (-2 / +16 lines)
Lines 1878-1884 Layout::layout_gnu_stack(bool seen_gnu_stack, uint64_t gnu_stack_flags, Link Here
1878
  else
1878
  else
1879
    {
1879
    {
1880
      this->input_with_gnu_stack_note_ = true;
1880
      this->input_with_gnu_stack_note_ = true;
1881
      if ((gnu_stack_flags & elfcpp::SHF_EXECINSTR) != 0)
1881
      if ((gnu_stack_flags & elfcpp::SHF_EXECINSTR) != 0)
1882
	{
1882
	{
1883
	  this->input_requires_executable_stack_ = true;
1883
	  this->input_requires_executable_stack_ = true;
1884
	  if (parameters->options().warn_execstack()
1884
	  if (parameters->options().warn_execstack()
Lines 2731-2737 Layout::create_executable_stack_info() Link Here
2731
    return;
2731
    return;
2732
  else
2732
  else
2733
    {
2733
    {
2734
      if (this->input_requires_executable_stack_)
2734
      if (this->input_requires_executable_stack_)
2735
	is_stack_executable = true;
2735
	is_stack_executable = true;
2736
      else if (this->input_without_gnu_stack_note_)
2736
      else if (this->input_without_gnu_stack_note_)
2737
	is_stack_executable =
2737
	is_stack_executable =
Lines 2757-2762 Layout::create_executable_stack_info() Link Here
2757
      if (is_stack_executable)
2757
      if (is_stack_executable)
2758
	flags |= elfcpp::PF_X;
2758
	flags |= elfcpp::PF_X;
2759
      this->make_output_segment(elfcpp::PT_GNU_STACK, flags);
2759
      this->make_output_segment(elfcpp::PT_GNU_STACK, flags);
2760
2761
      int pax_flags = elfcpp::PF_NORANDEXEC;
2762
      if (parameters->options().is_execheap_set()) {
2763
        if (parameters->options().is_heap_executable())
2764
          pax_flags |= elfcpp::PF_NOMPROTECT;
2765
        else
2766
          pax_flags |= elfcpp::PF_MPROTECT;
2767
      }
2768
2769
      if (is_stack_executable)
2770
        pax_flags |= elfcpp::PF_EMUTRAMP;
2771
      else
2772
        pax_flags |= elfcpp::PF_NOEMUTRAMP;
2773
      this->make_output_segment(elfcpp::PT_PAX_FLAGS, pax_flags);
2760
    }
2774
    }
2761
}
2775
}
2762
2776
(-)a/gold/options.cc (+8 lines)
Lines 912-917 namespace gold Link Here
912
General_options::General_options()
912
General_options::General_options()
913
  : printed_version_(false),
913
  : printed_version_(false),
914
    execstack_status_(EXECSTACK_FROM_INPUT),
914
    execstack_status_(EXECSTACK_FROM_INPUT),
915
    execheap_status_(EXECHEAP_FROM_INPUT),
915
    icf_status_(ICF_NONE),
916
    icf_status_(ICF_NONE),
916
    static_(false),
917
    static_(false),
917
    do_demangle_(false),
918
    do_demangle_(false),
Lines 1051-1056 General_options::finalize() Link Here
1051
  else if (this->noexecstack())
1052
  else if (this->noexecstack())
1052
    this->set_execstack_status(EXECSTACK_NO);
1053
    this->set_execstack_status(EXECSTACK_NO);
1053
1054
1055
  // execheap_status_ is a three-state variable; update it based on
1056
  // -z [no]execheap.
1057
  if (this->execheap())
1058
    this->set_execheap_status(EXECHEAP_YES);
1059
  else if (this->noexecheap())
1060
    this->set_execheap_status(EXECHEAP_NO);
1061
1054
  // icf_status_ is a three-state variable; update it based on the
1062
  // icf_status_ is a three-state variable; update it based on the
1055
  // value of this->icf().
1063
  // value of this->icf().
1056
  if (strcmp(this->icf(), "none") == 0)
1064
  if (strcmp(this->icf(), "none") == 0)
(-)a/gold/options.h (+31 lines)
Lines 1190-1195 class General_options Link Here
1190
              NULL);
1190
              NULL);
1191
  DEFINE_bool(execstack, options::DASH_Z, '\0', false,
1191
  DEFINE_bool(execstack, options::DASH_Z, '\0', false,
1192
              N_("Mark output as requiring executable stack"), NULL);
1192
              N_("Mark output as requiring executable stack"), NULL);
1193
  DEFINE_bool(execheap, options::DASH_Z, '\0', false,
1194
              N_("Mark output as requiring executable heap"), NULL);
1193
  DEFINE_bool(initfirst, options::DASH_Z, '\0', false,
1195
  DEFINE_bool(initfirst, options::DASH_Z, '\0', false,
1194
	      N_("Mark DSO to be initialized first at runtime"),
1196
	      N_("Mark DSO to be initialized first at runtime"),
1195
	      NULL);
1197
	      NULL);
Lines 1226-1231 class General_options Link Here
1226
	      NULL);
1228
	      NULL);
1227
  DEFINE_bool(noexecstack, options::DASH_Z, '\0', false,
1229
  DEFINE_bool(noexecstack, options::DASH_Z, '\0', false,
1228
              N_("Mark output as not requiring executable stack"), NULL);
1230
              N_("Mark output as not requiring executable stack"), NULL);
1231
  DEFINE_bool(noexecheap, options::DASH_Z, '\0', false,
1232
              N_("Mark output as not requiring executable heap"), NULL);
1229
  DEFINE_bool(now, options::DASH_Z, '\0', false,
1233
  DEFINE_bool(now, options::DASH_Z, '\0', false,
1230
	      N_("Mark object for immediate function binding"),
1234
	      N_("Mark object for immediate function binding"),
1231
	      NULL);
1235
	      NULL);
Lines 1327-1332 class General_options Link Here
1327
  is_stack_executable() const
1331
  is_stack_executable() const
1328
  { return this->execstack_status_ == EXECSTACK_YES; }
1332
  { return this->execstack_status_ == EXECSTACK_YES; }
1329
1333
1334
  // These are the best way to get access to the execheap state,
1335
  // not execheap() and noexecheap() which are hard to use properly.
1336
  bool
1337
  is_execheap_set() const
1338
  { return this->execheap_status_ != EXECHEAP_FROM_INPUT; }
1339
1340
  bool
1341
  is_heap_executable() const
1342
  { return this->execheap_status_ == EXECHEAP_YES; }
1343
1330
  bool
1344
  bool
1331
  icf_enabled() const
1345
  icf_enabled() const
1332
  { return this->icf_status_ != ICF_NONE; }
1346
  { return this->icf_status_ != ICF_NONE; }
Lines 1451-1456 class General_options Link Here
1451
    EXECSTACK_NO
1465
    EXECSTACK_NO
1452
  };
1466
  };
1453
1467
1468
  // Whether to mark the heap as executable.
1469
  enum Execheap
1470
  {
1471
    // Not set on command line.
1472
    EXECHEAP_FROM_INPUT,
1473
    // Mark the heap as executable (-z execheap).
1474
    EXECHEAP_YES,
1475
    // Mark the heap as not executable (-z noexecheap).
1476
    EXECHEAP_NO
1477
  };
1478
1454
  enum Icf_status
1479
  enum Icf_status
1455
  {
1480
  {
1456
    // Do not fold any functions (Default or --icf=none).
1481
    // Do not fold any functions (Default or --icf=none).
Lines 1470-1475 class General_options Link Here
1470
  { this->execstack_status_ = value; }
1495
  { this->execstack_status_ = value; }
1471
1496
1472
  void
1497
  void
1498
  set_execheap_status(Execheap value)
1499
  { this->execheap_status_ = value; }
1500
1501
  void
1473
  set_do_demangle(bool value)
1502
  set_do_demangle(bool value)
1474
  { this->do_demangle_ = value; }
1503
  { this->do_demangle_ = value; }
1475
1504
Lines 1498-1503 class General_options Link Here
1498
  bool printed_version_;
1527
  bool printed_version_;
1499
  // Whether to mark the stack as executable.
1528
  // Whether to mark the stack as executable.
1500
  Execstack execstack_status_;
1529
  Execstack execstack_status_;
1530
  // Whether to mark the heap as executable.
1531
  Execheap execheap_status_;
1501
  // Whether to do code folding.
1532
  // Whether to do code folding.
1502
  Icf_status icf_status_;
1533
  Icf_status icf_status_;
1503
  // Whether to do a static link.
1534
  // Whether to do a static link.
(-)a/gold/script.cc (+1 lines)
Lines 3262-3267 static struct Link Here
3262
  PHDR_TYPE(PT_TLS),
3262
  PHDR_TYPE(PT_TLS),
3263
  PHDR_TYPE(PT_GNU_EH_FRAME),
3263
  PHDR_TYPE(PT_GNU_EH_FRAME),
3264
  PHDR_TYPE(PT_GNU_STACK),
3264
  PHDR_TYPE(PT_GNU_STACK),
3265
  PHDR_TYPE(PT_PAX_FLAGS),
3265
  PHDR_TYPE(PT_GNU_RELRO)
3266
  PHDR_TYPE(PT_GNU_RELRO)
3266
};
3267
};
3267
3268

Return to bug 427704