| ... | ... | @@ -722,6 +722,10 @@ pub const Object = struct { |
| 722 | 722 | dg.addFnAttrString(llvm_func, "no-stack-arg-probe", ""); |
| 723 | 723 | } |
| 724 | 724 | |
| 725 | if (decl.@"linksection") |section| { |
| 726 | llvm_func.setSection(section); |
| 727 | } |
| 728 | |
| 725 | 729 | // Remove all the basic blocks of a function in order to start over, generating |
| 726 | 730 | // LLVM IR from an empty function body. |
| 727 | 731 | while (llvm_func.getFirstBasicBlock()) |bb| { |
| ... | ... | @@ -1107,6 +1111,11 @@ pub const Object = struct { |
| 1107 | 1111 | .hidden => llvm_global.setVisibility(.Hidden), |
| 1108 | 1112 | .protected => llvm_global.setVisibility(.Protected), |
| 1109 | 1113 | } |
| 1114 | if (exports[0].options.section) |section| { |
| 1115 | const section_z = try module.gpa.dupeZ(u8, section); |
| 1116 | defer module.gpa.free(section_z); |
| 1117 | llvm_global.setSection(section_z); |
| 1118 | } |
| 1110 | 1119 | if (decl.val.castTag(.variable)) |variable| { |
| 1111 | 1120 | if (variable.data.is_threadlocal) { |
| 1112 | 1121 | llvm_global.setThreadLocalMode(.GeneralDynamicTLSModel); |
| ... | ... | @@ -2183,6 +2192,7 @@ pub const DeclGen = struct { |
| 2183 | 2192 | const target = dg.module.getTarget(); |
| 2184 | 2193 | var global = try dg.resolveGlobalDecl(decl_index); |
| 2185 | 2194 | global.setAlignment(decl.getAlignment(target)); |
| 2195 | if (decl.@"linksection") |section| global.setSection(section); |
| 2186 | 2196 | assert(decl.has_tv); |
| 2187 | 2197 | const init_val = if (decl.val.castTag(.variable)) |payload| init_val: { |
| 2188 | 2198 | const variable = payload.data; |
| ... | ... | @@ -2216,6 +2226,7 @@ pub const DeclGen = struct { |
| 2216 | 2226 | new_global.setLinkage(global.getLinkage()); |
| 2217 | 2227 | new_global.setUnnamedAddr(global.getUnnamedAddress()); |
| 2218 | 2228 | new_global.setAlignment(global.getAlignment()); |
| 2229 | if (decl.@"linksection") |section| new_global.setSection(section); |
| 2219 | 2230 | new_global.setInitializer(llvm_init); |
| 2220 | 2231 | // replaceAllUsesWith requires the type to be unchanged. So we bitcast |
| 2221 | 2232 | // the new global to the old type and use that as the thing to replace |