Commit 9cf29ef
committed
linker: detect duplicate exported definitions without imports
The duplicate-export check in GetImportExportPairs() only triggers when
iterating over imports. If no module imports a symbol, the linker never
looks up the export table for that name, so multiple modules can each
export the same function and spvtools::Link() silently accepts them
instead of reporting an error.
Add a standalone pass over the exports map before the import-matching
loop to reject links where the same symbol name is exported by more
than one module. This correctly handles LinkOnceODR symbols because
they are already deduplicated into a single export entry by the
preceding linkonce processing.
The existing size > 1 check in the import-matching loop is now
redundant and has been removed.
Add a test for the case where two modules export the same symbol
but neither imports it.
Fixes the piglit clLinkProgram test where two modules each define
get_number() with Export linkage but neither imports it.1 parent 113784c commit 9cf29ef
2 files changed
Lines changed: 44 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
504 | 504 | | |
505 | 505 | | |
506 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
507 | 518 | | |
508 | 519 | | |
509 | 520 | | |
| |||
512 | 523 | | |
513 | 524 | | |
514 | 525 | | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | 526 | | |
520 | 527 | | |
521 | 528 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
237 | 270 | | |
238 | 271 | | |
239 | 272 | | |
| |||
0 commit comments