@@ -463,16 +463,49 @@ public enum CodeGenOptLevel {
463463}
464464
465465/// The relocation model types supported by LLVM.
466- public enum RelocMode {
466+ public enum RelocationModel {
467467 /// Generated code will assume the default for a particular target architecture.
468468 case `default`
469469 /// Generated code will exist at static offsets.
470470 case `static`
471- /// Generated code will be Position-Independent .
471+ /// Generated code will be position-independent .
472472 case pic
473- /// Generated code will not be Position-Independent and may be used in static
473+ /// Generated code will not be position-independent and may be used in static
474474 /// or dynamic executables but not necessarily a shared library.
475475 case dynamicNoPIC
476+ /// Generated code will be compiled in read-only position independent mode.
477+ /// In this mode, all read-only data and functions are at a link-time constant
478+ /// offset from the program counter.
479+ ///
480+ /// ROPI is not supported by all target architectures and calling conventions.
481+ /// It is a particular feature of ARM targets, though.
482+ ///
483+ /// ROPI may be useful to avoid committing to compile-time constant locations
484+ /// for code in memory. This may be useful in the following circumstances:
485+ ///
486+ /// - Code is loaded dynamically.
487+ /// - Code is loaded into memory conditionally, or in an undefined order.
488+ /// - Code is mapped into different addresses during different executions.
489+ case ropi
490+ /// Generated code will be compiled in read-write position independent mode.
491+ /// In this mode, all writable data is at a link-time constant offset from the
492+ /// static base register.
493+ ///
494+ /// RWPI is not supported by all target architectures and calling conventions.
495+ /// It is a particular feature of ARM targets, though.
496+ ///
497+ /// RWPI may be useful to avoid committing to compile-time constant locations
498+ /// for code in memory. This is particularly useful for data that must be
499+ /// multiply instantiated for reentrant routines, as each thread executing a
500+ /// reentrant routine will recieve its own copy of any data in
501+ /// read-write segments.
502+ case rwpi
503+ /// Combines the `ropi` and `rwpi` modes. Generated code will be compiled in
504+ /// both read-only and read-write position independent modes. All read-only
505+ /// data appears at a link-time constant offset from the program counter,
506+ /// and all writable data appears at a link-time constant offset from the
507+ /// static base register.
508+ case ropiRWPI
476509
477510 /// Returns the underlying `LLVMRelocMode` associated with this
478511 /// relocation model.
@@ -482,6 +515,9 @@ public enum RelocMode {
482515 case . static: return LLVMRelocStatic
483516 case . pic: return LLVMRelocPIC
484517 case . dynamicNoPIC: return LLVMRelocDynamicNoPic
518+ case . ropi: return LLVMRelocROPI
519+ case . rwpi: return LLVMRelocRWPI
520+ case . ropiRWPI: return LLVMRelocROPI_RWPI
485521 }
486522 }
487523}
0 commit comments