mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-10-29 05:40:27 -04:00 
			
		
		
		
	treewide: retain sections to prevent linker garbage collection
The linker may remove sections that are actually used when "--gc-sections" and "-z start-stop-gc" is set. Add the `retain` attribute to prevent that. Furthermore, fix the alignment for `pwtest_suite_decl` objects. See: #2292 See: https://lld.llvm.org/ELF/start-stop-gc.html See: https://github.com/systemd/systemd/issues/21847 See: https://github.com/systemd/systemd/pull/21855
This commit is contained in:
		
							parent
							
								
									22fc9eec35
								
							
						
					
					
						commit
						e28a052105
					
				
					 3 changed files with 6 additions and 3 deletions
				
			
		|  | @ -47,6 +47,7 @@ struct module_info { | ||||||
| 
 | 
 | ||||||
| #define DEFINE_MODULE_INFO(name)					\ | #define DEFINE_MODULE_INFO(name)					\ | ||||||
| 	__attribute__((used))						\ | 	__attribute__((used))						\ | ||||||
|  | 	__attribute__((retain))						\ | ||||||
| 	__attribute__((section("pw_mod_pulse_modules")))		\ | 	__attribute__((section("pw_mod_pulse_modules")))		\ | ||||||
| 	__attribute__((aligned(__alignof__(struct module_info))))	\ | 	__attribute__((aligned(__alignof__(struct module_info))))	\ | ||||||
| 	const struct module_info name | 	const struct module_info name | ||||||
|  |  | ||||||
|  | @ -131,7 +131,7 @@ void _pwtest_add(struct pwtest_context *ctx, | ||||||
| struct pwtest_suite_decl { | struct pwtest_suite_decl { | ||||||
| 	const char *name; | 	const char *name; | ||||||
| 	enum pwtest_result (*setup)(struct pwtest_context *, struct pwtest_suite *); | 	enum pwtest_result (*setup)(struct pwtest_context *, struct pwtest_suite *); | ||||||
| } __attribute__((aligned(16))); | }; | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| #endif /* PWTEST_IMPLEMENTATION_H */ | #endif /* PWTEST_IMPLEMENTATION_H */ | ||||||
|  |  | ||||||
|  | @ -494,9 +494,11 @@ enum pwtest_arg { | ||||||
|  */ |  */ | ||||||
| #define PWTEST_SUITE(cname) \ | #define PWTEST_SUITE(cname) \ | ||||||
| 	static enum pwtest_result (cname##__setup)(struct pwtest_context *ctx, struct pwtest_suite *suite); \ | 	static enum pwtest_result (cname##__setup)(struct pwtest_context *ctx, struct pwtest_suite *suite); \ | ||||||
| 	static const struct pwtest_suite_decl _test_suite \ |  | ||||||
| 	__attribute__((used)) \ | 	__attribute__((used)) \ | ||||||
| 	__attribute((section("pwtest_suite_section"))) = { \ | 	__attribute__((retain)) \ | ||||||
|  | 	__attribute__((section("pwtest_suite_section"))) \ | ||||||
|  | 	__attribute__((aligned(__alignof__(struct pwtest_suite_decl)))) \ | ||||||
|  | 	static const struct pwtest_suite_decl _test_suite = { \ | ||||||
| 	   .name = #cname, \ | 	   .name = #cname, \ | ||||||
| 	   .setup = cname##__setup, \ | 	   .setup = cname##__setup, \ | ||||||
| 	}; \ | 	}; \ | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Barnabás Pőcze
						Barnabás Pőcze