~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/powerpc/kernel/reloc_32.S

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/powerpc/kernel/reloc_32.S (Version linux-6.12-rc7) and /arch/i386/kernel/reloc_32.S (Version linux-2.4.37.11)


  1 /* SPDX-License-Identifier: GPL-2.0-or-later *    
  2 /*                                                
  3  * Code to process dynamic relocations for PPC    
  4  *                                                
  5  * Copyrights (C) IBM Corporation, 2011.          
  6  *      Author: Suzuki Poulose <suzuki@in.ibm.c    
  7  *                                                
  8  *  - Based on ppc64 code - reloc_64.S            
  9  */                                               
 10                                                   
 11 #include <asm/ppc_asm.h>                          
 12                                                   
 13 /* Dynamic section table entry tags */            
 14 DT_RELA = 7                     /* Tag for Elf    
 15 DT_RELASZ = 8                   /* Size of the    
 16 DT_RELAENT = 9                  /* Size of one    
 17                                                   
 18 STN_UNDEF = 0                   /* Undefined s    
 19 STB_LOCAL = 0                   /* Local bindi    
 20                                                   
 21 R_PPC_ADDR16_LO = 4             /* Lower half     
 22 R_PPC_ADDR16_HI = 5             /* Upper half     
 23 R_PPC_ADDR16_HA = 6             /* High Adjust    
 24 R_PPC_RELATIVE = 22                               
 25                                                   
 26 /*                                                
 27  * r3 = desired final address                     
 28  */                                               
 29                                                   
 30 _GLOBAL(relocate)                                 
 31                                                   
 32         mflr    r0              /* Save our LR    
 33         bcl     20,31,$+4       /* Find our cu    
 34 0:      mflr    r12             /* Make it acc    
 35         mtlr    r0                                
 36                                                   
 37         lwz     r11, (p_dyn - 0b)(r12)            
 38         add     r11, r11, r12   /* runtime add    
 39         lwz     r9, (p_rela - 0b)(r12)            
 40         add     r9, r9, r12     /* runtime add    
 41         lwz     r10, (p_st - 0b)(r12)             
 42         add     r10, r10, r12   /* runtime add    
 43         lwz     r13, (p_sym - 0b)(r12)            
 44         add     r13, r13, r12   /* runtime add    
 45                                                   
 46         /*                                        
 47          * Scan the dynamic section for RELA,     
 48          */                                       
 49         li      r6, 0                             
 50         li      r7, 0                             
 51         li      r8, 0                             
 52 1:      lwz     r5, 0(r11)      /* ELF_Dyn.d_t    
 53         cmpwi   r5, 0           /* End of ELF_    
 54         beq     eodyn                             
 55         cmpwi   r5, DT_RELA                       
 56         bne     relasz                            
 57         lwz     r7, 4(r11)      /* r7 = rela.l    
 58         b       skip                              
 59 relasz:                                           
 60         cmpwi   r5, DT_RELASZ                     
 61         bne     relaent                           
 62         lwz     r8, 4(r11)      /* r8 = Total     
 63         b       skip                              
 64 relaent:                                          
 65         cmpwi   r5, DT_RELAENT                    
 66         bne     skip                              
 67         lwz     r6, 4(r11)      /* r6 = Size o    
 68 skip:                                             
 69         addi    r11, r11, 8                       
 70         b       1b                                
 71 eodyn:                          /* End of Dyn     
 72                                                   
 73         /* Check if we have found all the entr    
 74         cmpwi   r7, 0                             
 75         beq     done                              
 76         cmpwi   r8, 0                             
 77         beq     done                              
 78         cmpwi   r6, 0                             
 79         beq     done                              
 80                                                   
 81                                                   
 82         /*                                        
 83          * Work out the current offset from th    
 84          * section.                               
 85          *  cur_offset[r7] = rela.run[r9] - re    
 86          *  _stext.link[r12] = _stext.run[r10]    
 87          *  final_offset[r3] = _stext.final[r3    
 88          */                                       
 89         subf    r7, r7, r9      /* cur_offset     
 90         subf    r12, r7, r10                      
 91         subf    r3, r12, r3     /* final_offse    
 92                                                   
 93         subf    r8, r6, r8      /* relaz -= re    
 94         /*                                        
 95          * Scan through the .rela table and pr    
 96          * r9   - points to the current .rela     
 97          * r13  - points to the symbol table      
 98          */                                       
 99                                                   
100         /*                                        
101          * Check if we have a relocation based    
102          * r5 will hold the value of the symbo    
103          */                                       
104 applyrela:                                        
105         lwz     r4, 4(r9)               /* r4     
106         srwi    r5, r4, 8               /* ELF    
107         cmpwi   r5, STN_UNDEF   /* sym == STN_    
108         beq     get_type        /* value = 0 *    
109         /* Find the value of the symbol at ind    
110         slwi    r5, r5, 4               /* r5     
111         add     r12, r13, r5    /* r12 = &__dy    
112                                                   
113         /*                                        
114          * GNU ld has a bug, where dynamic rel    
115          * STB_LOCAL symbols, the value should    
116          * to be zero. - Alan Modra               
117          */                                       
118         /* XXX: Do we need to check if we are     
119         lbz     r5, 12(r12)     /* r5 = dyn_sy    
120         extrwi  r5, r5, 4, 24   /* r5 = ELF32_    
121         cmpwi   r5, STB_LOCAL   /* st_value =     
122         beq     get_type        /* We have r5     
123         lwz     r5, 4(r12)      /* r5 = __dyn_    
124                                                   
125 get_type:                                         
126         /* Load the relocation type to r4 */      
127         extrwi  r4, r4, 8, 24   /* r4 = ELF32_    
128                                                   
129         /* R_PPC_RELATIVE */                      
130         cmpwi   r4, R_PPC_RELATIVE                
131         bne     hi16                              
132         lwz     r4, 0(r9)       /* r_offset */    
133         lwz     r0, 8(r9)       /* r_addend */    
134         add     r0, r0, r3      /* final adden    
135         stwx    r0, r4, r7      /* memory[r4+r    
136         b       nxtrela         /* continue */    
137                                                   
138         /* R_PPC_ADDR16_HI */                     
139 hi16:                                             
140         cmpwi   r4, R_PPC_ADDR16_HI               
141         bne     ha16                              
142         lwz     r4, 0(r9)       /* r_offset */    
143         lwz     r0, 8(r9)       /* r_addend */    
144         add     r0, r0, r3                        
145         add     r0, r0, r5      /* r0 = (S+A+O    
146         extrwi  r0, r0, 16, 0   /* r0 = (r0 >>    
147         b       store_half                        
148                                                   
149         /* R_PPC_ADDR16_HA */                     
150 ha16:                                             
151         cmpwi   r4, R_PPC_ADDR16_HA               
152         bne     lo16                              
153         lwz     r4, 0(r9)       /* r_offset */    
154         lwz     r0, 8(r9)       /* r_addend */    
155         add     r0, r0, r3                        
156         add     r0, r0, r5      /* r0 = (S+A+O    
157         extrwi  r5, r0, 1, 16   /* Extract bit    
158         extrwi  r0, r0, 16, 0   /* r0 = (r0 >>    
159         add     r0, r0, r5      /* Add it to r    
160         b       store_half                        
161                                                   
162         /* R_PPC_ADDR16_LO */                     
163 lo16:                                             
164         cmpwi   r4, R_PPC_ADDR16_LO               
165         bne     unknown_type                      
166         lwz     r4, 0(r9)       /* r_offset */    
167         lwz     r0, 8(r9)       /* r_addend */    
168         add     r0, r0, r3                        
169         add     r0, r0, r5      /* r0 = (S+A+O    
170         extrwi  r0, r0, 16, 16  /* r0 &= 0xfff    
171         /* Fall through to */                     
172                                                   
173         /* Store half word */                     
174 store_half:                                       
175         sthx    r0, r4, r7      /* memory[r4+r    
176                                                   
177 nxtrela:                                          
178         /*                                        
179          * We have to flush the modified instr    
180          * main storage from the d-cache. And     
181          * cached instructions in i-cache whic    
182          *                                        
183          * We delay the sync / isync operation    
184          * we won't be executing the modified     
185          * we return from here.                   
186          */                                       
187         dcbst   r4,r7                             
188         sync                    /* Ensure the     
189         icbi    r4,r7                             
190 unknown_type:                                     
191         cmpwi   r8, 0           /* relasz = 0     
192         ble     done                              
193         add     r9, r9, r6      /* move to nex    
194         subf    r8, r6, r8      /* relasz -= r    
195         b       applyrela                         
196                                                   
197 done:                                             
198         sync                    /* Wait for th    
199         isync                   /* Discard pre    
200         blr                                       
201                                                   
202 p_dyn:          .long   __dynamic_start - 0b      
203 p_rela:         .long   __rela_dyn_start - 0b     
204 p_sym:          .long   __dynamic_symtab - 0b     
205 p_st:           .long   _stext - 0b               
                                                      

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php