As well as ELF linker does, retain all data segments named X referenced
through __start_X or __stop_X.
For example, FOO_MD should not be stripped in the below case, but it's currently mis-stripped
llvm @FOO_MD = global [4 x i8] c"bar\00", section "foo_md", align 1 @__start_foo_md = external constant i8* @__stop_foo_md = external constant i8* @llvm.used = appending global [1 x i8*] [i8* bitcast (i32 ()* @foo_md_size to i8*)], section "llvm.metadata" define i32 @foo_md_size() { entry: ret i32 sub ( i32 ptrtoint (i8** @__stop_foo_md to i32), i32 ptrtoint (i8** @__start_foo_md to i32) ) }
This fixes https://github.com/llvm/llvm-project/issues/55839
We are trying to move away from .ll tests and stick to use .s tests as they tend to be easier to read/faster/fewer dependencies.
Would you mind converting this test to .s?