File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
117
117
118
118
let mut entries = Vec :: new ( ) ;
119
119
120
- for ( entry_name, entry) in self . entries {
120
+ for ( mut entry_name, entry) in self . entries {
121
121
// FIXME only read the symbol table of the object files to avoid having to keep all
122
122
// object files in memory at once, or read them twice.
123
123
let data = match entry {
@@ -140,6 +140,23 @@ impl<'a> ArchiveBuilder<'a> for ArArchiveBuilder<'a> {
140
140
} ;
141
141
142
142
if !self . no_builtin_ranlib {
143
+ if symbol_table. contains_key ( & entry_name) {
144
+ // The ar crate can't handle creating a symbol table in case of multiple archive
145
+ // members with the same name. Work around this by prepending a number until we
146
+ // get a unique name.
147
+ for i in 1 .. {
148
+ let new_name = format ! ( "{}_" , i)
149
+ . into_bytes ( )
150
+ . into_iter ( )
151
+ . chain ( entry_name. iter ( ) . copied ( ) )
152
+ . collect :: < Vec < _ > > ( ) ;
153
+ if !symbol_table. contains_key ( & new_name) {
154
+ entry_name = new_name;
155
+ break ;
156
+ }
157
+ }
158
+ }
159
+
143
160
match object:: File :: parse ( & * data) {
144
161
Ok ( object) => {
145
162
symbol_table. insert (
You can’t perform that action at this time.
0 commit comments