Skip to content

Commit b1354b8

Browse files
committed
c++, contracts, Darwin: Fix local symbols for linker.
Darwin partitions objects into 'atoms' based on linker-visible symbols. If these are not present, and weak and non-weak sections overlap we get spurious warnings. We need the contract violation constants and the source locations to be visible. In addition, this fixes those symbols such that we do not unconditionally emit periods into the names (some assemblers do not accept this). TODO: fix other cases at some stage. Signed-off-by: Iain Sandoe <[email protected]>
1 parent 5128291 commit b1354b8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

gcc/config/darwin.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,10 @@ extern GTY(()) section * darwin_sections[NUM_DARWIN_SECTIONS];
996996
sprintf (LABEL, "*%s%ld", "lASAN", (long)(NUM));\
997997
else if (strcmp ("LTRAMP", PREFIX) == 0) \
998998
sprintf (LABEL, "*%s%ld", "lTRAMP", (long)(NUM));\
999+
else if (strcmp ("Lcontract_violation", PREFIX) == 0) \
1000+
sprintf (LABEL, "*%s%ld", "lcontract_violation", (long)(NUM));\
1001+
else if (strcmp ("Lsrc_loc_impl.", PREFIX) == 0) \
1002+
sprintf (LABEL, "*%s%ld", "lsrc_loc_impl", (long)(NUM));\
9991003
else \
10001004
sprintf (LABEL, "*%s%ld", PREFIX, (long)(NUM)); \
10011005
} while (0)

gcc/cp/contracts.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,7 +1999,7 @@ static tree
19991999
build_contracts_source_location (location_t loc)
20002000
{
20012001
tree impl_ = contracts_tu_local_named_var
2002-
(loc, "Lsrc_loc_impl.",
2002+
(loc, "Lsrc_loc_impl",
20032003
get_contracts_source_location_impl_type (), /*is_const*/true);
20042004

20052005
DECL_INITIAL (impl_) = build_contracts_source_location_impl (loc);
@@ -2255,7 +2255,7 @@ build_contract_violation_P2900 (tree contract, bool is_const)
22552255
TREE_STATIC (ctor) = true;
22562256

22572257
tree viol_ = contracts_tu_local_named_var
2258-
(EXPR_LOCATION (contract), "Lcontract_violation.",
2258+
(EXPR_LOCATION (contract), "Lcontract_violation",
22592259
get_pseudo_contract_violation_type (), /*is_const*/true);
22602260

22612261
TREE_CONSTANT (viol_) = is_const;

0 commit comments

Comments
 (0)